index
int64
repo_id
string
file_path
string
content
string
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/BrokerRegistrationRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.BrokerRegistrationRequestData.*; public class BrokerRegistrationRequestDataJsonConverter { public static BrokerRegistrationRequestData read(JsonNode _node, short _version) { BrokerRegistrationRequestData _object = new BrokerRegistrationRequestData(); JsonNode _brokerIdNode = _node.get("brokerId"); if (_brokerIdNode == null) { throw new RuntimeException("BrokerRegistrationRequestData: unable to locate field 'brokerId', which is mandatory in version " + _version); } else { _object.brokerId = MessageUtil.jsonNodeToInt(_brokerIdNode, "BrokerRegistrationRequestData"); } JsonNode _clusterIdNode = _node.get("clusterId"); if (_clusterIdNode == null) { throw new RuntimeException("BrokerRegistrationRequestData: unable to locate field 'clusterId', which is mandatory in version " + _version); } else { if (!_clusterIdNode.isTextual()) { throw new RuntimeException("BrokerRegistrationRequestData expected a string type, but got " + _node.getNodeType()); } _object.clusterId = _clusterIdNode.asText(); } JsonNode _incarnationIdNode = _node.get("incarnationId"); if (_incarnationIdNode == null) { throw new RuntimeException("BrokerRegistrationRequestData: unable to locate field 'incarnationId', which is mandatory in version " + _version); } else { if (!_incarnationIdNode.isTextual()) { throw new RuntimeException("BrokerRegistrationRequestData expected a JSON string type, but got " + _node.getNodeType()); } _object.incarnationId = Uuid.fromString(_incarnationIdNode.asText()); } JsonNode _listenersNode = _node.get("listeners"); if (_listenersNode == null) { throw new RuntimeException("BrokerRegistrationRequestData: unable to locate field 'listeners', which is mandatory in version " + _version); } else { if (!_listenersNode.isArray()) { throw new RuntimeException("BrokerRegistrationRequestData expected a JSON array, but got " + _node.getNodeType()); } ListenerCollection _collection = new ListenerCollection(_listenersNode.size()); _object.listeners = _collection; for (JsonNode _element : _listenersNode) { _collection.add(ListenerJsonConverter.read(_element, _version)); } } JsonNode _featuresNode = _node.get("features"); if (_featuresNode == null) { throw new RuntimeException("BrokerRegistrationRequestData: unable to locate field 'features', which is mandatory in version " + _version); } else { if (!_featuresNode.isArray()) { throw new RuntimeException("BrokerRegistrationRequestData expected a JSON array, but got " + _node.getNodeType()); } FeatureCollection _collection = new FeatureCollection(_featuresNode.size()); _object.features = _collection; for (JsonNode _element : _featuresNode) { _collection.add(FeatureJsonConverter.read(_element, _version)); } } JsonNode _rackNode = _node.get("rack"); if (_rackNode == null) { throw new RuntimeException("BrokerRegistrationRequestData: unable to locate field 'rack', which is mandatory in version " + _version); } else { if (_rackNode.isNull()) { _object.rack = null; } else { if (!_rackNode.isTextual()) { throw new RuntimeException("BrokerRegistrationRequestData expected a string type, but got " + _node.getNodeType()); } _object.rack = _rackNode.asText(); } } JsonNode _isMigratingZkBrokerNode = _node.get("isMigratingZkBroker"); if (_isMigratingZkBrokerNode == null) { if (_version >= 1) { throw new RuntimeException("BrokerRegistrationRequestData: unable to locate field 'isMigratingZkBroker', which is mandatory in version " + _version); } else { _object.isMigratingZkBroker = false; } } else { if (!_isMigratingZkBrokerNode.isBoolean()) { throw new RuntimeException("BrokerRegistrationRequestData expected Boolean type, but got " + _node.getNodeType()); } _object.isMigratingZkBroker = _isMigratingZkBrokerNode.asBoolean(); } return _object; } public static JsonNode write(BrokerRegistrationRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("brokerId", new IntNode(_object.brokerId)); _node.set("clusterId", new TextNode(_object.clusterId)); _node.set("incarnationId", new TextNode(_object.incarnationId.toString())); ArrayNode _listenersArray = new ArrayNode(JsonNodeFactory.instance); for (Listener _element : _object.listeners) { _listenersArray.add(ListenerJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("listeners", _listenersArray); ArrayNode _featuresArray = new ArrayNode(JsonNodeFactory.instance); for (Feature _element : _object.features) { _featuresArray.add(FeatureJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("features", _featuresArray); if (_object.rack == null) { _node.set("rack", NullNode.instance); } else { _node.set("rack", new TextNode(_object.rack)); } if (_version >= 1) { _node.set("isMigratingZkBroker", BooleanNode.valueOf(_object.isMigratingZkBroker)); } else { if (_object.isMigratingZkBroker) { throw new UnsupportedVersionException("Attempted to write a non-default isMigratingZkBroker at version " + _version); } } return _node; } public static JsonNode write(BrokerRegistrationRequestData _object, short _version) { return write(_object, _version, true); } public static class FeatureJsonConverter { public static Feature read(JsonNode _node, short _version) { Feature _object = new Feature(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("Feature: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("Feature expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _minSupportedVersionNode = _node.get("minSupportedVersion"); if (_minSupportedVersionNode == null) { throw new RuntimeException("Feature: unable to locate field 'minSupportedVersion', which is mandatory in version " + _version); } else { _object.minSupportedVersion = MessageUtil.jsonNodeToShort(_minSupportedVersionNode, "Feature"); } JsonNode _maxSupportedVersionNode = _node.get("maxSupportedVersion"); if (_maxSupportedVersionNode == null) { throw new RuntimeException("Feature: unable to locate field 'maxSupportedVersion', which is mandatory in version " + _version); } else { _object.maxSupportedVersion = MessageUtil.jsonNodeToShort(_maxSupportedVersionNode, "Feature"); } return _object; } public static JsonNode write(Feature _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); _node.set("minSupportedVersion", new ShortNode(_object.minSupportedVersion)); _node.set("maxSupportedVersion", new ShortNode(_object.maxSupportedVersion)); return _node; } public static JsonNode write(Feature _object, short _version) { return write(_object, _version, true); } } public static class ListenerJsonConverter { public static Listener read(JsonNode _node, short _version) { Listener _object = new Listener(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("Listener: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("Listener expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _hostNode = _node.get("host"); if (_hostNode == null) { throw new RuntimeException("Listener: unable to locate field 'host', which is mandatory in version " + _version); } else { if (!_hostNode.isTextual()) { throw new RuntimeException("Listener expected a string type, but got " + _node.getNodeType()); } _object.host = _hostNode.asText(); } JsonNode _portNode = _node.get("port"); if (_portNode == null) { throw new RuntimeException("Listener: unable to locate field 'port', which is mandatory in version " + _version); } else { _object.port = MessageUtil.jsonNodeToUnsignedShort(_portNode, "Listener"); } JsonNode _securityProtocolNode = _node.get("securityProtocol"); if (_securityProtocolNode == null) { throw new RuntimeException("Listener: unable to locate field 'securityProtocol', which is mandatory in version " + _version); } else { _object.securityProtocol = MessageUtil.jsonNodeToShort(_securityProtocolNode, "Listener"); } return _object; } public static JsonNode write(Listener _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); _node.set("host", new TextNode(_object.host)); _node.set("port", new IntNode(_object.port)); _node.set("securityProtocol", new ShortNode(_object.securityProtocol)); return _node; } public static JsonNode write(Listener _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/BrokerRegistrationResponseData.java
/* * 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.util.ArrayList; import java.util.List; import org.apache.kafka.common.protocol.ApiMessage; 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.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 BrokerRegistrationResponseData implements ApiMessage { int throttleTimeMs; short errorCode; long brokerEpoch; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("throttle_time_ms", Type.INT32, "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 error code, or 0 if there was no error."), new Field("broker_epoch", Type.INT64, "The broker's assigned epoch, or -1 if none was assigned."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public BrokerRegistrationResponseData(Readable _readable, short _version) { read(_readable, _version); } public BrokerRegistrationResponseData() { this.throttleTimeMs = 0; this.errorCode = (short) 0; this.brokerEpoch = -1L; } @Override public short apiKey() { return 62; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); this.errorCode = _readable.readShort(); this.brokerEpoch = _readable.readLong(); 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); _writable.writeLong(brokerEpoch); 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); _size.addBytes(8); 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 BrokerRegistrationResponseData)) return false; BrokerRegistrationResponseData other = (BrokerRegistrationResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (errorCode != other.errorCode) return false; if (brokerEpoch != other.brokerEpoch) 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 + ((int) (brokerEpoch >> 32) ^ (int) brokerEpoch); return hashCode; } @Override public BrokerRegistrationResponseData duplicate() { BrokerRegistrationResponseData _duplicate = new BrokerRegistrationResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; _duplicate.errorCode = errorCode; _duplicate.brokerEpoch = brokerEpoch; return _duplicate; } @Override public String toString() { return "BrokerRegistrationResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", errorCode=" + errorCode + ", brokerEpoch=" + brokerEpoch + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public short errorCode() { return this.errorCode; } public long brokerEpoch() { return this.brokerEpoch; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public BrokerRegistrationResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public BrokerRegistrationResponseData setErrorCode(short v) { this.errorCode = v; return this; } public BrokerRegistrationResponseData setBrokerEpoch(long v) { this.brokerEpoch = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/BrokerRegistrationResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.BrokerRegistrationResponseData.*; public class BrokerRegistrationResponseDataJsonConverter { public static BrokerRegistrationResponseData read(JsonNode _node, short _version) { BrokerRegistrationResponseData _object = new BrokerRegistrationResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("BrokerRegistrationResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "BrokerRegistrationResponseData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("BrokerRegistrationResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "BrokerRegistrationResponseData"); } JsonNode _brokerEpochNode = _node.get("brokerEpoch"); if (_brokerEpochNode == null) { throw new RuntimeException("BrokerRegistrationResponseData: unable to locate field 'brokerEpoch', which is mandatory in version " + _version); } else { _object.brokerEpoch = MessageUtil.jsonNodeToLong(_brokerEpochNode, "BrokerRegistrationResponseData"); } return _object; } public static JsonNode write(BrokerRegistrationResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); _node.set("errorCode", new ShortNode(_object.errorCode)); _node.set("brokerEpoch", new LongNode(_object.brokerEpoch)); return _node; } public static JsonNode write(BrokerRegistrationResponseData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ConsumerGroupHeartbeatRequestData.java
/* * 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.Arrays; 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 org.apache.kafka.common.utils.Bytes; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class ConsumerGroupHeartbeatRequestData implements ApiMessage { String groupId; String memberId; int memberEpoch; String instanceId; String rackId; int rebalanceTimeoutMs; List<String> subscribedTopicNames; String subscribedTopicRegex; String serverAssignor; List<Assignor> clientAssignors; List<TopicPartitions> topicPartitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("group_id", Type.COMPACT_STRING, "The group identifier."), new Field("member_id", Type.COMPACT_STRING, "The member id generated by the coordinator. The member id must be kept during the entire lifetime of the member."), new Field("member_epoch", Type.INT32, "The current member epoch; 0 to join the group; -1 to leave the group; -2 to indicate that the static member will rejoin."), new Field("instance_id", Type.COMPACT_NULLABLE_STRING, "null if not provided or if it didn't change since the last heartbeat; the instance Id otherwise."), new Field("rack_id", Type.COMPACT_NULLABLE_STRING, "null if not provided or if it didn't change since the last heartbeat; the rack ID of consumer otherwise."), new Field("rebalance_timeout_ms", Type.INT32, "-1 if it didn't chance since the last heartbeat; the maximum time in milliseconds that the coordinator will wait on the member to revoke its partitions otherwise."), new Field("subscribed_topic_names", CompactArrayOf.nullable(Type.COMPACT_STRING), "null if it didn't change since the last heartbeat; the subscribed topic names otherwise."), new Field("subscribed_topic_regex", Type.COMPACT_NULLABLE_STRING, "null if it didn't change since the last heartbeat; the subscribed topic regex otherwise"), new Field("server_assignor", Type.COMPACT_NULLABLE_STRING, "null if not used or if it didn't change since the last heartbeat; the server side assignor to use otherwise."), new Field("client_assignors", CompactArrayOf.nullable(Assignor.SCHEMA_0), "null if not used or if it didn't change since the last heartbeat; the list of client-side assignors otherwise."), new Field("topic_partitions", CompactArrayOf.nullable(TopicPartitions.SCHEMA_0), "null if it didn't change since the last heartbeat; the partitions owned by the member."), 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 ConsumerGroupHeartbeatRequestData(Readable _readable, short _version) { read(_readable, _version); } public ConsumerGroupHeartbeatRequestData() { this.groupId = ""; this.memberId = ""; this.memberEpoch = 0; this.instanceId = null; this.rackId = null; this.rebalanceTimeoutMs = -1; this.subscribedTopicNames = null; this.subscribedTopicRegex = null; this.serverAssignor = null; this.clientAssignors = null; this.topicPartitions = null; } @Override public short apiKey() { return 68; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field groupId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field groupId had invalid length " + length); } else { this.groupId = _readable.readString(length); } } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field memberId was serialized as 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(); { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.instanceId = null; } else if (length > 0x7fff) { throw new RuntimeException("string field instanceId had invalid length " + length); } else { this.instanceId = _readable.readString(length); } } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.rackId = null; } else if (length > 0x7fff) { throw new RuntimeException("string field rackId had invalid length " + length); } else { this.rackId = _readable.readString(length); } } this.rebalanceTimeoutMs = _readable.readInt(); { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.subscribedTopicNames = 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field subscribedTopicNames element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field subscribedTopicNames element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.subscribedTopicNames = newCollection; } } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.subscribedTopicRegex = null; } else if (length > 0x7fff) { throw new RuntimeException("string field subscribedTopicRegex had invalid length " + length); } else { this.subscribedTopicRegex = _readable.readString(length); } } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.serverAssignor = null; } else if (length > 0x7fff) { throw new RuntimeException("string field serverAssignor had invalid length " + length); } else { this.serverAssignor = _readable.readString(length); } } { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.clientAssignors = 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<Assignor> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new Assignor(_readable, _version)); } this.clientAssignors = newCollection; } } { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.topicPartitions = 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<TopicPartitions> 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; { byte[] _stringBytes = _cache.getSerializedValue(groupId); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(memberId); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeInt(memberEpoch); if (instanceId == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(instanceId); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } if (rackId == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(rackId); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeInt(rebalanceTimeoutMs); if (subscribedTopicNames == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(subscribedTopicNames.size() + 1); for (String subscribedTopicNamesElement : subscribedTopicNames) { { byte[] _stringBytes = _cache.getSerializedValue(subscribedTopicNamesElement); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } } if (subscribedTopicRegex == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(subscribedTopicRegex); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } if (serverAssignor == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(serverAssignor); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } if (clientAssignors == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(clientAssignors.size() + 1); for (Assignor clientAssignorsElement : clientAssignors) { clientAssignorsElement.write(_writable, _cache, _version); } } if (topicPartitions == null) { _writable.writeUnsignedVarint(0); } else { _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; { byte[] _stringBytes = groupId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'groupId' field is too long to be serialized"); } _cache.cacheSerializedValue(groupId, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } { 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); if (instanceId == null) { _size.addBytes(1); } else { byte[] _stringBytes = instanceId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'instanceId' field is too long to be serialized"); } _cache.cacheSerializedValue(instanceId, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } if (rackId == null) { _size.addBytes(1); } else { byte[] _stringBytes = rackId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'rackId' field is too long to be serialized"); } _cache.cacheSerializedValue(rackId, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _size.addBytes(4); if (subscribedTopicNames == null) { _size.addBytes(1); } else { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(subscribedTopicNames.size() + 1)); for (String subscribedTopicNamesElement : subscribedTopicNames) { byte[] _stringBytes = subscribedTopicNamesElement.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'subscribedTopicNamesElement' field is too long to be serialized"); } _cache.cacheSerializedValue(subscribedTopicNamesElement, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } } if (subscribedTopicRegex == null) { _size.addBytes(1); } else { byte[] _stringBytes = subscribedTopicRegex.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'subscribedTopicRegex' field is too long to be serialized"); } _cache.cacheSerializedValue(subscribedTopicRegex, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } if (serverAssignor == null) { _size.addBytes(1); } else { byte[] _stringBytes = serverAssignor.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'serverAssignor' field is too long to be serialized"); } _cache.cacheSerializedValue(serverAssignor, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } if (clientAssignors == null) { _size.addBytes(1); } else { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(clientAssignors.size() + 1)); for (Assignor clientAssignorsElement : clientAssignors) { clientAssignorsElement.addSize(_size, _cache, _version); } } if (topicPartitions == null) { _size.addBytes(1); } else { _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 ConsumerGroupHeartbeatRequestData)) return false; ConsumerGroupHeartbeatRequestData other = (ConsumerGroupHeartbeatRequestData) obj; if (this.groupId == null) { if (other.groupId != null) return false; } else { if (!this.groupId.equals(other.groupId)) 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 (this.instanceId == null) { if (other.instanceId != null) return false; } else { if (!this.instanceId.equals(other.instanceId)) return false; } if (this.rackId == null) { if (other.rackId != null) return false; } else { if (!this.rackId.equals(other.rackId)) return false; } if (rebalanceTimeoutMs != other.rebalanceTimeoutMs) return false; if (this.subscribedTopicNames == null) { if (other.subscribedTopicNames != null) return false; } else { if (!this.subscribedTopicNames.equals(other.subscribedTopicNames)) return false; } if (this.subscribedTopicRegex == null) { if (other.subscribedTopicRegex != null) return false; } else { if (!this.subscribedTopicRegex.equals(other.subscribedTopicRegex)) return false; } if (this.serverAssignor == null) { if (other.serverAssignor != null) return false; } else { if (!this.serverAssignor.equals(other.serverAssignor)) return false; } if (this.clientAssignors == null) { if (other.clientAssignors != null) return false; } else { if (!this.clientAssignors.equals(other.clientAssignors)) return false; } 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 + (groupId == null ? 0 : groupId.hashCode()); hashCode = 31 * hashCode + (memberId == null ? 0 : memberId.hashCode()); hashCode = 31 * hashCode + memberEpoch; hashCode = 31 * hashCode + (instanceId == null ? 0 : instanceId.hashCode()); hashCode = 31 * hashCode + (rackId == null ? 0 : rackId.hashCode()); hashCode = 31 * hashCode + rebalanceTimeoutMs; hashCode = 31 * hashCode + (subscribedTopicNames == null ? 0 : subscribedTopicNames.hashCode()); hashCode = 31 * hashCode + (subscribedTopicRegex == null ? 0 : subscribedTopicRegex.hashCode()); hashCode = 31 * hashCode + (serverAssignor == null ? 0 : serverAssignor.hashCode()); hashCode = 31 * hashCode + (clientAssignors == null ? 0 : clientAssignors.hashCode()); hashCode = 31 * hashCode + (topicPartitions == null ? 0 : topicPartitions.hashCode()); return hashCode; } @Override public ConsumerGroupHeartbeatRequestData duplicate() { ConsumerGroupHeartbeatRequestData _duplicate = new ConsumerGroupHeartbeatRequestData(); _duplicate.groupId = groupId; _duplicate.memberId = memberId; _duplicate.memberEpoch = memberEpoch; if (instanceId == null) { _duplicate.instanceId = null; } else { _duplicate.instanceId = instanceId; } if (rackId == null) { _duplicate.rackId = null; } else { _duplicate.rackId = rackId; } _duplicate.rebalanceTimeoutMs = rebalanceTimeoutMs; if (subscribedTopicNames == null) { _duplicate.subscribedTopicNames = null; } else { ArrayList<String> newSubscribedTopicNames = new ArrayList<String>(subscribedTopicNames.size()); for (String _element : subscribedTopicNames) { newSubscribedTopicNames.add(_element); } _duplicate.subscribedTopicNames = newSubscribedTopicNames; } if (subscribedTopicRegex == null) { _duplicate.subscribedTopicRegex = null; } else { _duplicate.subscribedTopicRegex = subscribedTopicRegex; } if (serverAssignor == null) { _duplicate.serverAssignor = null; } else { _duplicate.serverAssignor = serverAssignor; } if (clientAssignors == null) { _duplicate.clientAssignors = null; } else { ArrayList<Assignor> newClientAssignors = new ArrayList<Assignor>(clientAssignors.size()); for (Assignor _element : clientAssignors) { newClientAssignors.add(_element.duplicate()); } _duplicate.clientAssignors = newClientAssignors; } if (topicPartitions == null) { _duplicate.topicPartitions = null; } else { ArrayList<TopicPartitions> newTopicPartitions = new ArrayList<TopicPartitions>(topicPartitions.size()); for (TopicPartitions _element : topicPartitions) { newTopicPartitions.add(_element.duplicate()); } _duplicate.topicPartitions = newTopicPartitions; } return _duplicate; } @Override public String toString() { return "ConsumerGroupHeartbeatRequestData(" + "groupId=" + ((groupId == null) ? "null" : "'" + groupId.toString() + "'") + ", memberId=" + ((memberId == null) ? "null" : "'" + memberId.toString() + "'") + ", memberEpoch=" + memberEpoch + ", instanceId=" + ((instanceId == null) ? "null" : "'" + instanceId.toString() + "'") + ", rackId=" + ((rackId == null) ? "null" : "'" + rackId.toString() + "'") + ", rebalanceTimeoutMs=" + rebalanceTimeoutMs + ", subscribedTopicNames=" + ((subscribedTopicNames == null) ? "null" : MessageUtil.deepToString(subscribedTopicNames.iterator())) + ", subscribedTopicRegex=" + ((subscribedTopicRegex == null) ? "null" : "'" + subscribedTopicRegex.toString() + "'") + ", serverAssignor=" + ((serverAssignor == null) ? "null" : "'" + serverAssignor.toString() + "'") + ", clientAssignors=" + ((clientAssignors == null) ? "null" : MessageUtil.deepToString(clientAssignors.iterator())) + ", topicPartitions=" + ((topicPartitions == null) ? "null" : MessageUtil.deepToString(topicPartitions.iterator())) + ")"; } public String groupId() { return this.groupId; } public String memberId() { return this.memberId; } public int memberEpoch() { return this.memberEpoch; } public String instanceId() { return this.instanceId; } public String rackId() { return this.rackId; } public int rebalanceTimeoutMs() { return this.rebalanceTimeoutMs; } public List<String> subscribedTopicNames() { return this.subscribedTopicNames; } public String subscribedTopicRegex() { return this.subscribedTopicRegex; } public String serverAssignor() { return this.serverAssignor; } public List<Assignor> clientAssignors() { return this.clientAssignors; } public List<TopicPartitions> topicPartitions() { return this.topicPartitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ConsumerGroupHeartbeatRequestData setGroupId(String v) { this.groupId = v; return this; } public ConsumerGroupHeartbeatRequestData setMemberId(String v) { this.memberId = v; return this; } public ConsumerGroupHeartbeatRequestData setMemberEpoch(int v) { this.memberEpoch = v; return this; } public ConsumerGroupHeartbeatRequestData setInstanceId(String v) { this.instanceId = v; return this; } public ConsumerGroupHeartbeatRequestData setRackId(String v) { this.rackId = v; return this; } public ConsumerGroupHeartbeatRequestData setRebalanceTimeoutMs(int v) { this.rebalanceTimeoutMs = v; return this; } public ConsumerGroupHeartbeatRequestData setSubscribedTopicNames(List<String> v) { this.subscribedTopicNames = v; return this; } public ConsumerGroupHeartbeatRequestData setSubscribedTopicRegex(String v) { this.subscribedTopicRegex = v; return this; } public ConsumerGroupHeartbeatRequestData setServerAssignor(String v) { this.serverAssignor = v; return this; } public ConsumerGroupHeartbeatRequestData setClientAssignors(List<Assignor> v) { this.clientAssignors = v; return this; } public ConsumerGroupHeartbeatRequestData setTopicPartitions(List<TopicPartitions> v) { this.topicPartitions = v; return this; } public static class Assignor implements Message { String name; short minimumVersion; short maximumVersion; byte reason; short metadataVersion; byte[] metadataBytes; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.COMPACT_STRING, "The name of the assignor."), new Field("minimum_version", Type.INT16, "The minimum supported version for the metadata."), new Field("maximum_version", Type.INT16, "The maximum supported version for the metadata."), new Field("reason", Type.INT8, "The reason of the metadata update."), new Field("metadata_version", Type.INT16, "The version of the metadata."), new Field("metadata_bytes", Type.COMPACT_BYTES, "The metadata."), 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 Assignor(Readable _readable, short _version) { read(_readable, _version); } public Assignor() { this.name = ""; this.minimumVersion = (short) 0; this.maximumVersion = (short) 0; this.reason = (byte) 0; this.metadataVersion = (short) 0; this.metadataBytes = Bytes.EMPTY; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of Assignor"); } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } this.minimumVersion = _readable.readShort(); this.maximumVersion = _readable.readShort(); this.reason = _readable.readByte(); this.metadataVersion = _readable.readShort(); { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field metadataBytes was serialized as null"); } else { byte[] newBytes = _readable.readArray(length); this.metadataBytes = newBytes; } } 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; { byte[] _stringBytes = _cache.getSerializedValue(name); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeShort(minimumVersion); _writable.writeShort(maximumVersion); _writable.writeByte(reason); _writable.writeShort(metadataVersion); _writable.writeUnsignedVarint(metadataBytes.length + 1); _writable.writeByteArray(metadataBytes); 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 Assignor"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _size.addBytes(2); _size.addBytes(2); _size.addBytes(1); _size.addBytes(2); { _size.addBytes(metadataBytes.length); _size.addBytes(ByteUtils.sizeOfUnsignedVarint(metadataBytes.length + 1)); } 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 Assignor)) return false; Assignor other = (Assignor) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (minimumVersion != other.minimumVersion) return false; if (maximumVersion != other.maximumVersion) return false; if (reason != other.reason) return false; if (metadataVersion != other.metadataVersion) return false; if (!Arrays.equals(this.metadataBytes, other.metadataBytes)) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + minimumVersion; hashCode = 31 * hashCode + maximumVersion; hashCode = 31 * hashCode + reason; hashCode = 31 * hashCode + metadataVersion; hashCode = 31 * hashCode + Arrays.hashCode(metadataBytes); return hashCode; } @Override public Assignor duplicate() { Assignor _duplicate = new Assignor(); _duplicate.name = name; _duplicate.minimumVersion = minimumVersion; _duplicate.maximumVersion = maximumVersion; _duplicate.reason = reason; _duplicate.metadataVersion = metadataVersion; _duplicate.metadataBytes = MessageUtil.duplicate(metadataBytes); return _duplicate; } @Override public String toString() { return "Assignor(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", minimumVersion=" + minimumVersion + ", maximumVersion=" + maximumVersion + ", reason=" + reason + ", metadataVersion=" + metadataVersion + ", metadataBytes=" + Arrays.toString(metadataBytes) + ")"; } public String name() { return this.name; } public short minimumVersion() { return this.minimumVersion; } public short maximumVersion() { return this.maximumVersion; } public byte reason() { return this.reason; } public short metadataVersion() { return this.metadataVersion; } public byte[] metadataBytes() { return this.metadataBytes; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public Assignor setName(String v) { this.name = v; return this; } public Assignor setMinimumVersion(short v) { this.minimumVersion = v; return this; } public Assignor setMaximumVersion(short v) { this.maximumVersion = v; return this; } public Assignor setReason(byte v) { this.reason = v; return this; } public Assignor setMetadataVersion(short v) { this.metadataVersion = v; return this; } public Assignor setMetadataBytes(byte[] v) { this.metadataBytes = v; return this; } } public static class TopicPartitions implements Message { Uuid topicId; List<Integer> partitions; private List<RawTaggedField> _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<Integer>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicPartitions"); } 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<Integer> 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; if (_version > 0) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicPartitions"); } _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<Integer> newPartitions = new ArrayList<Integer>(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<Integer> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicPartitions setTopicId(Uuid v) { this.topicId = v; return this; } public TopicPartitions setPartitions(List<Integer> v) { this.partitions = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ConsumerGroupHeartbeatRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BinaryNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import java.util.Arrays; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.ConsumerGroupHeartbeatRequestData.*; public class ConsumerGroupHeartbeatRequestDataJsonConverter { public static ConsumerGroupHeartbeatRequestData read(JsonNode _node, short _version) { ConsumerGroupHeartbeatRequestData _object = new ConsumerGroupHeartbeatRequestData(); JsonNode _groupIdNode = _node.get("groupId"); if (_groupIdNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'groupId', which is mandatory in version " + _version); } else { if (!_groupIdNode.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a string type, but got " + _node.getNodeType()); } _object.groupId = _groupIdNode.asText(); } JsonNode _memberIdNode = _node.get("memberId"); if (_memberIdNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'memberId', which is mandatory in version " + _version); } else { if (!_memberIdNode.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a string type, but got " + _node.getNodeType()); } _object.memberId = _memberIdNode.asText(); } JsonNode _memberEpochNode = _node.get("memberEpoch"); if (_memberEpochNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'memberEpoch', which is mandatory in version " + _version); } else { _object.memberEpoch = MessageUtil.jsonNodeToInt(_memberEpochNode, "ConsumerGroupHeartbeatRequestData"); } JsonNode _instanceIdNode = _node.get("instanceId"); if (_instanceIdNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'instanceId', which is mandatory in version " + _version); } else { if (_instanceIdNode.isNull()) { _object.instanceId = null; } else { if (!_instanceIdNode.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a string type, but got " + _node.getNodeType()); } _object.instanceId = _instanceIdNode.asText(); } } JsonNode _rackIdNode = _node.get("rackId"); if (_rackIdNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'rackId', which is mandatory in version " + _version); } else { if (_rackIdNode.isNull()) { _object.rackId = null; } else { if (!_rackIdNode.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a string type, but got " + _node.getNodeType()); } _object.rackId = _rackIdNode.asText(); } } JsonNode _rebalanceTimeoutMsNode = _node.get("rebalanceTimeoutMs"); if (_rebalanceTimeoutMsNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'rebalanceTimeoutMs', which is mandatory in version " + _version); } else { _object.rebalanceTimeoutMs = MessageUtil.jsonNodeToInt(_rebalanceTimeoutMsNode, "ConsumerGroupHeartbeatRequestData"); } JsonNode _subscribedTopicNamesNode = _node.get("subscribedTopicNames"); if (_subscribedTopicNamesNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'subscribedTopicNames', which is mandatory in version " + _version); } else { if (_subscribedTopicNamesNode.isNull()) { _object.subscribedTopicNames = null; } else { if (!_subscribedTopicNamesNode.isArray()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<String> _collection = new ArrayList<String>(_subscribedTopicNamesNode.size()); _object.subscribedTopicNames = _collection; for (JsonNode _element : _subscribedTopicNamesNode) { if (!_element.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData element expected a string type, but got " + _node.getNodeType()); } _collection.add(_element.asText()); } } } JsonNode _subscribedTopicRegexNode = _node.get("subscribedTopicRegex"); if (_subscribedTopicRegexNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'subscribedTopicRegex', which is mandatory in version " + _version); } else { if (_subscribedTopicRegexNode.isNull()) { _object.subscribedTopicRegex = null; } else { if (!_subscribedTopicRegexNode.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a string type, but got " + _node.getNodeType()); } _object.subscribedTopicRegex = _subscribedTopicRegexNode.asText(); } } JsonNode _serverAssignorNode = _node.get("serverAssignor"); if (_serverAssignorNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'serverAssignor', which is mandatory in version " + _version); } else { if (_serverAssignorNode.isNull()) { _object.serverAssignor = null; } else { if (!_serverAssignorNode.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a string type, but got " + _node.getNodeType()); } _object.serverAssignor = _serverAssignorNode.asText(); } } JsonNode _clientAssignorsNode = _node.get("clientAssignors"); if (_clientAssignorsNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'clientAssignors', which is mandatory in version " + _version); } else { if (_clientAssignorsNode.isNull()) { _object.clientAssignors = null; } else { if (!_clientAssignorsNode.isArray()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Assignor> _collection = new ArrayList<Assignor>(_clientAssignorsNode.size()); _object.clientAssignors = _collection; for (JsonNode _element : _clientAssignorsNode) { _collection.add(AssignorJsonConverter.read(_element, _version)); } } } JsonNode _topicPartitionsNode = _node.get("topicPartitions"); if (_topicPartitionsNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData: unable to locate field 'topicPartitions', which is mandatory in version " + _version); } else { if (_topicPartitionsNode.isNull()) { _object.topicPartitions = null; } else { if (!_topicPartitionsNode.isArray()) { throw new RuntimeException("ConsumerGroupHeartbeatRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TopicPartitions> _collection = new ArrayList<TopicPartitions>(_topicPartitionsNode.size()); _object.topicPartitions = _collection; for (JsonNode _element : _topicPartitionsNode) { _collection.add(TopicPartitionsJsonConverter.read(_element, _version)); } } } return _object; } public static JsonNode write(ConsumerGroupHeartbeatRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("groupId", new TextNode(_object.groupId)); _node.set("memberId", new TextNode(_object.memberId)); _node.set("memberEpoch", new IntNode(_object.memberEpoch)); if (_object.instanceId == null) { _node.set("instanceId", NullNode.instance); } else { _node.set("instanceId", new TextNode(_object.instanceId)); } if (_object.rackId == null) { _node.set("rackId", NullNode.instance); } else { _node.set("rackId", new TextNode(_object.rackId)); } _node.set("rebalanceTimeoutMs", new IntNode(_object.rebalanceTimeoutMs)); if (_object.subscribedTopicNames == null) { _node.set("subscribedTopicNames", NullNode.instance); } else { ArrayNode _subscribedTopicNamesArray = new ArrayNode(JsonNodeFactory.instance); for (String _element : _object.subscribedTopicNames) { _subscribedTopicNamesArray.add(new TextNode(_element)); } _node.set("subscribedTopicNames", _subscribedTopicNamesArray); } if (_object.subscribedTopicRegex == null) { _node.set("subscribedTopicRegex", NullNode.instance); } else { _node.set("subscribedTopicRegex", new TextNode(_object.subscribedTopicRegex)); } if (_object.serverAssignor == null) { _node.set("serverAssignor", NullNode.instance); } else { _node.set("serverAssignor", new TextNode(_object.serverAssignor)); } if (_object.clientAssignors == null) { _node.set("clientAssignors", NullNode.instance); } else { ArrayNode _clientAssignorsArray = new ArrayNode(JsonNodeFactory.instance); for (Assignor _element : _object.clientAssignors) { _clientAssignorsArray.add(AssignorJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("clientAssignors", _clientAssignorsArray); } if (_object.topicPartitions == null) { _node.set("topicPartitions", NullNode.instance); } else { ArrayNode _topicPartitionsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicPartitions _element : _object.topicPartitions) { _topicPartitionsArray.add(TopicPartitionsJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topicPartitions", _topicPartitionsArray); } return _node; } public static JsonNode write(ConsumerGroupHeartbeatRequestData _object, short _version) { return write(_object, _version, true); } public static class AssignorJsonConverter { public static Assignor read(JsonNode _node, short _version) { Assignor _object = new Assignor(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("Assignor: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("Assignor expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _minimumVersionNode = _node.get("minimumVersion"); if (_minimumVersionNode == null) { throw new RuntimeException("Assignor: unable to locate field 'minimumVersion', which is mandatory in version " + _version); } else { _object.minimumVersion = MessageUtil.jsonNodeToShort(_minimumVersionNode, "Assignor"); } JsonNode _maximumVersionNode = _node.get("maximumVersion"); if (_maximumVersionNode == null) { throw new RuntimeException("Assignor: unable to locate field 'maximumVersion', which is mandatory in version " + _version); } else { _object.maximumVersion = MessageUtil.jsonNodeToShort(_maximumVersionNode, "Assignor"); } JsonNode _reasonNode = _node.get("reason"); if (_reasonNode == null) { throw new RuntimeException("Assignor: unable to locate field 'reason', which is mandatory in version " + _version); } else { _object.reason = MessageUtil.jsonNodeToByte(_reasonNode, "Assignor"); } JsonNode _metadataVersionNode = _node.get("metadataVersion"); if (_metadataVersionNode == null) { throw new RuntimeException("Assignor: unable to locate field 'metadataVersion', which is mandatory in version " + _version); } else { _object.metadataVersion = MessageUtil.jsonNodeToShort(_metadataVersionNode, "Assignor"); } JsonNode _metadataBytesNode = _node.get("metadataBytes"); if (_metadataBytesNode == null) { throw new RuntimeException("Assignor: unable to locate field 'metadataBytes', which is mandatory in version " + _version); } else { _object.metadataBytes = MessageUtil.jsonNodeToBinary(_metadataBytesNode, "Assignor"); } return _object; } public static JsonNode write(Assignor _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); _node.set("minimumVersion", new ShortNode(_object.minimumVersion)); _node.set("maximumVersion", new ShortNode(_object.maximumVersion)); _node.set("reason", new ShortNode(_object.reason)); _node.set("metadataVersion", new ShortNode(_object.metadataVersion)); _node.set("metadataBytes", new BinaryNode(Arrays.copyOf(_object.metadataBytes, _object.metadataBytes.length))); return _node; } public static JsonNode write(Assignor _object, short _version) { return write(_object, _version, true); } } public static class TopicPartitionsJsonConverter { public static TopicPartitions read(JsonNode _node, short _version) { TopicPartitions _object = new TopicPartitions(); JsonNode _topicIdNode = _node.get("topicId"); if (_topicIdNode == null) { throw new RuntimeException("TopicPartitions: unable to locate field 'topicId', which is mandatory in version " + _version); } else { if (!_topicIdNode.isTextual()) { throw new RuntimeException("TopicPartitions expected a JSON string type, but got " + _node.getNodeType()); } _object.topicId = Uuid.fromString(_topicIdNode.asText()); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicPartitions: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicPartitions expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "TopicPartitions element")); } } return _object; } public static JsonNode write(TopicPartitions _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topicId", new TextNode(_object.topicId.toString())); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.partitions) { _partitionsArray.add(new IntNode(_element)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicPartitions _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ConsumerGroupHeartbeatResponseData.java
/* * 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.Arrays; 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 org.apache.kafka.common.utils.Bytes; 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; boolean shouldComputeAssignment; int heartbeatIntervalMs; Assignment assignment; private List<RawTaggedField> _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("should_compute_assignment", Type.BOOLEAN, "True if the member should compute the assignment for the group."), 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.shouldComputeAssignment = false; 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 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.shouldComputeAssignment = _readable.readByte() != 0; 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.writeByte(shouldComputeAssignment ? (byte) 1 : (byte) 0); _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(1); _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 (shouldComputeAssignment != other.shouldComputeAssignment) 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 + (shouldComputeAssignment ? 1231 : 1237); 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.shouldComputeAssignment = shouldComputeAssignment; _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 + ", shouldComputeAssignment=" + (shouldComputeAssignment ? "true" : "false") + ", 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 boolean shouldComputeAssignment() { return this.shouldComputeAssignment; } public int heartbeatIntervalMs() { return this.heartbeatIntervalMs; } public Assignment assignment() { return this.assignment; } @Override public List<RawTaggedField> 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 setShouldComputeAssignment(boolean v) { this.shouldComputeAssignment = 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 { byte error; List<TopicPartitions> assignedTopicPartitions; List<TopicPartitions> pendingTopicPartitions; short metadataVersion; byte[] metadataBytes; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error", Type.INT8, "The assigned error."), new Field("assigned_topic_partitions", new CompactArrayOf(TopicPartitions.SCHEMA_0), "The partitions assigned to the member that can be used immediately."), new Field("pending_topic_partitions", new CompactArrayOf(TopicPartitions.SCHEMA_0), "The partitions assigned to the member that cannot be used because they are not released by their former owners yet."), new Field("metadata_version", Type.INT16, "The version of the metadata."), new Field("metadata_bytes", Type.COMPACT_BYTES, "The assigned metadata."), 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.error = (byte) 0; this.assignedTopicPartitions = new ArrayList<TopicPartitions>(0); this.pendingTopicPartitions = new ArrayList<TopicPartitions>(0); this.metadataVersion = (short) 0; this.metadataBytes = Bytes.EMPTY; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of Assignment"); } this.error = _readable.readByte(); { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field assignedTopicPartitions 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<TopicPartitions> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicPartitions(_readable, _version)); } this.assignedTopicPartitions = newCollection; } } { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field pendingTopicPartitions 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<TopicPartitions> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicPartitions(_readable, _version)); } this.pendingTopicPartitions = newCollection; } } this.metadataVersion = _readable.readShort(); { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field metadataBytes was serialized as null"); } else { byte[] newBytes = _readable.readArray(length); this.metadataBytes = newBytes; } } 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.writeByte(error); _writable.writeUnsignedVarint(assignedTopicPartitions.size() + 1); for (TopicPartitions assignedTopicPartitionsElement : assignedTopicPartitions) { assignedTopicPartitionsElement.write(_writable, _cache, _version); } _writable.writeUnsignedVarint(pendingTopicPartitions.size() + 1); for (TopicPartitions pendingTopicPartitionsElement : pendingTopicPartitions) { pendingTopicPartitionsElement.write(_writable, _cache, _version); } _writable.writeShort(metadataVersion); _writable.writeUnsignedVarint(metadataBytes.length + 1); _writable.writeByteArray(metadataBytes); 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(1); { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(assignedTopicPartitions.size() + 1)); for (TopicPartitions assignedTopicPartitionsElement : assignedTopicPartitions) { assignedTopicPartitionsElement.addSize(_size, _cache, _version); } } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(pendingTopicPartitions.size() + 1)); for (TopicPartitions pendingTopicPartitionsElement : pendingTopicPartitions) { pendingTopicPartitionsElement.addSize(_size, _cache, _version); } } _size.addBytes(2); { _size.addBytes(metadataBytes.length); _size.addBytes(ByteUtils.sizeOfUnsignedVarint(metadataBytes.length + 1)); } 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 (error != other.error) return false; if (this.assignedTopicPartitions == null) { if (other.assignedTopicPartitions != null) return false; } else { if (!this.assignedTopicPartitions.equals(other.assignedTopicPartitions)) return false; } if (this.pendingTopicPartitions == null) { if (other.pendingTopicPartitions != null) return false; } else { if (!this.pendingTopicPartitions.equals(other.pendingTopicPartitions)) return false; } if (metadataVersion != other.metadataVersion) return false; if (!Arrays.equals(this.metadataBytes, other.metadataBytes)) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + error; hashCode = 31 * hashCode + (assignedTopicPartitions == null ? 0 : assignedTopicPartitions.hashCode()); hashCode = 31 * hashCode + (pendingTopicPartitions == null ? 0 : pendingTopicPartitions.hashCode()); hashCode = 31 * hashCode + metadataVersion; hashCode = 31 * hashCode + Arrays.hashCode(metadataBytes); return hashCode; } @Override public Assignment duplicate() { Assignment _duplicate = new Assignment(); _duplicate.error = error; ArrayList<TopicPartitions> newAssignedTopicPartitions = new ArrayList<TopicPartitions>(assignedTopicPartitions.size()); for (TopicPartitions _element : assignedTopicPartitions) { newAssignedTopicPartitions.add(_element.duplicate()); } _duplicate.assignedTopicPartitions = newAssignedTopicPartitions; ArrayList<TopicPartitions> newPendingTopicPartitions = new ArrayList<TopicPartitions>(pendingTopicPartitions.size()); for (TopicPartitions _element : pendingTopicPartitions) { newPendingTopicPartitions.add(_element.duplicate()); } _duplicate.pendingTopicPartitions = newPendingTopicPartitions; _duplicate.metadataVersion = metadataVersion; _duplicate.metadataBytes = MessageUtil.duplicate(metadataBytes); return _duplicate; } @Override public String toString() { return "Assignment(" + "error=" + error + ", assignedTopicPartitions=" + MessageUtil.deepToString(assignedTopicPartitions.iterator()) + ", pendingTopicPartitions=" + MessageUtil.deepToString(pendingTopicPartitions.iterator()) + ", metadataVersion=" + metadataVersion + ", metadataBytes=" + Arrays.toString(metadataBytes) + ")"; } public byte error() { return this.error; } public List<TopicPartitions> assignedTopicPartitions() { return this.assignedTopicPartitions; } public List<TopicPartitions> pendingTopicPartitions() { return this.pendingTopicPartitions; } public short metadataVersion() { return this.metadataVersion; } public byte[] metadataBytes() { return this.metadataBytes; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public Assignment setError(byte v) { this.error = v; return this; } public Assignment setAssignedTopicPartitions(List<TopicPartitions> v) { this.assignedTopicPartitions = v; return this; } public Assignment setPendingTopicPartitions(List<TopicPartitions> v) { this.pendingTopicPartitions = v; return this; } public Assignment setMetadataVersion(short v) { this.metadataVersion = v; return this; } public Assignment setMetadataBytes(byte[] v) { this.metadataBytes = v; return this; } } public static class TopicPartitions implements Message { Uuid topicId; List<Integer> partitions; private List<RawTaggedField> _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<Integer>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 32767; } @Override public 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<Integer> 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<Integer> newPartitions = new ArrayList<Integer>(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<Integer> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicPartitions setTopicId(Uuid v) { this.topicId = v; return this; } public TopicPartitions setPartitions(List<Integer> v) { this.partitions = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ConsumerGroupHeartbeatResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BinaryNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import java.util.Arrays; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.ConsumerGroupHeartbeatResponseData.*; public class ConsumerGroupHeartbeatResponseDataJsonConverter { public static ConsumerGroupHeartbeatResponseData read(JsonNode _node, short _version) { ConsumerGroupHeartbeatResponseData _object = new ConsumerGroupHeartbeatResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "ConsumerGroupHeartbeatResponseData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "ConsumerGroupHeartbeatResponseData"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _memberIdNode = _node.get("memberId"); if (_memberIdNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData: unable to locate field 'memberId', which is mandatory in version " + _version); } else { if (_memberIdNode.isNull()) { _object.memberId = null; } else { if (!_memberIdNode.isTextual()) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData expected a string type, but got " + _node.getNodeType()); } _object.memberId = _memberIdNode.asText(); } } JsonNode _memberEpochNode = _node.get("memberEpoch"); if (_memberEpochNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData: unable to locate field 'memberEpoch', which is mandatory in version " + _version); } else { _object.memberEpoch = MessageUtil.jsonNodeToInt(_memberEpochNode, "ConsumerGroupHeartbeatResponseData"); } JsonNode _shouldComputeAssignmentNode = _node.get("shouldComputeAssignment"); if (_shouldComputeAssignmentNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData: unable to locate field 'shouldComputeAssignment', which is mandatory in version " + _version); } else { if (!_shouldComputeAssignmentNode.isBoolean()) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData expected Boolean type, but got " + _node.getNodeType()); } _object.shouldComputeAssignment = _shouldComputeAssignmentNode.asBoolean(); } JsonNode _heartbeatIntervalMsNode = _node.get("heartbeatIntervalMs"); if (_heartbeatIntervalMsNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData: unable to locate field 'heartbeatIntervalMs', which is mandatory in version " + _version); } else { _object.heartbeatIntervalMs = MessageUtil.jsonNodeToInt(_heartbeatIntervalMsNode, "ConsumerGroupHeartbeatResponseData"); } JsonNode _assignmentNode = _node.get("assignment"); if (_assignmentNode == null) { throw new RuntimeException("ConsumerGroupHeartbeatResponseData: unable to locate field 'assignment', which is mandatory in version " + _version); } else { if (_assignmentNode.isNull()) { _object.assignment = null; } else { _object.assignment = AssignmentJsonConverter.read(_assignmentNode, _version); } } return _object; } public static JsonNode write(ConsumerGroupHeartbeatResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } if (_object.memberId == null) { _node.set("memberId", NullNode.instance); } else { _node.set("memberId", new TextNode(_object.memberId)); } _node.set("memberEpoch", new IntNode(_object.memberEpoch)); _node.set("shouldComputeAssignment", BooleanNode.valueOf(_object.shouldComputeAssignment)); _node.set("heartbeatIntervalMs", new IntNode(_object.heartbeatIntervalMs)); if (_object.assignment == null) { _node.set("assignment", NullNode.instance); } else { _node.set("assignment", AssignmentJsonConverter.write(_object.assignment, _version, _serializeRecords)); } return _node; } public static JsonNode write(ConsumerGroupHeartbeatResponseData _object, short _version) { return write(_object, _version, true); } public static class AssignmentJsonConverter { public static Assignment read(JsonNode _node, short _version) { Assignment _object = new Assignment(); JsonNode _errorNode = _node.get("error"); if (_errorNode == null) { throw new RuntimeException("Assignment: unable to locate field 'error', which is mandatory in version " + _version); } else { _object.error = MessageUtil.jsonNodeToByte(_errorNode, "Assignment"); } JsonNode _assignedTopicPartitionsNode = _node.get("assignedTopicPartitions"); if (_assignedTopicPartitionsNode == null) { throw new RuntimeException("Assignment: unable to locate field 'assignedTopicPartitions', which is mandatory in version " + _version); } else { if (!_assignedTopicPartitionsNode.isArray()) { throw new RuntimeException("Assignment expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TopicPartitions> _collection = new ArrayList<TopicPartitions>(_assignedTopicPartitionsNode.size()); _object.assignedTopicPartitions = _collection; for (JsonNode _element : _assignedTopicPartitionsNode) { _collection.add(TopicPartitionsJsonConverter.read(_element, _version)); } } JsonNode _pendingTopicPartitionsNode = _node.get("pendingTopicPartitions"); if (_pendingTopicPartitionsNode == null) { throw new RuntimeException("Assignment: unable to locate field 'pendingTopicPartitions', which is mandatory in version " + _version); } else { if (!_pendingTopicPartitionsNode.isArray()) { throw new RuntimeException("Assignment expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TopicPartitions> _collection = new ArrayList<TopicPartitions>(_pendingTopicPartitionsNode.size()); _object.pendingTopicPartitions = _collection; for (JsonNode _element : _pendingTopicPartitionsNode) { _collection.add(TopicPartitionsJsonConverter.read(_element, _version)); } } JsonNode _metadataVersionNode = _node.get("metadataVersion"); if (_metadataVersionNode == null) { throw new RuntimeException("Assignment: unable to locate field 'metadataVersion', which is mandatory in version " + _version); } else { _object.metadataVersion = MessageUtil.jsonNodeToShort(_metadataVersionNode, "Assignment"); } JsonNode _metadataBytesNode = _node.get("metadataBytes"); if (_metadataBytesNode == null) { throw new RuntimeException("Assignment: unable to locate field 'metadataBytes', which is mandatory in version " + _version); } else { _object.metadataBytes = MessageUtil.jsonNodeToBinary(_metadataBytesNode, "Assignment"); } return _object; } public static JsonNode write(Assignment _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("error", new ShortNode(_object.error)); ArrayNode _assignedTopicPartitionsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicPartitions _element : _object.assignedTopicPartitions) { _assignedTopicPartitionsArray.add(TopicPartitionsJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("assignedTopicPartitions", _assignedTopicPartitionsArray); ArrayNode _pendingTopicPartitionsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicPartitions _element : _object.pendingTopicPartitions) { _pendingTopicPartitionsArray.add(TopicPartitionsJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("pendingTopicPartitions", _pendingTopicPartitionsArray); _node.set("metadataVersion", new ShortNode(_object.metadataVersion)); _node.set("metadataBytes", new BinaryNode(Arrays.copyOf(_object.metadataBytes, _object.metadataBytes.length))); return _node; } public static JsonNode write(Assignment _object, short _version) { return write(_object, _version, true); } } public static class TopicPartitionsJsonConverter { public static TopicPartitions read(JsonNode _node, short _version) { TopicPartitions _object = new TopicPartitions(); JsonNode _topicIdNode = _node.get("topicId"); if (_topicIdNode == null) { throw new RuntimeException("TopicPartitions: unable to locate field 'topicId', which is mandatory in version " + _version); } else { if (!_topicIdNode.isTextual()) { throw new RuntimeException("TopicPartitions expected a JSON string type, but got " + _node.getNodeType()); } _object.topicId = Uuid.fromString(_topicIdNode.asText()); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicPartitions: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicPartitions expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "TopicPartitions element")); } } return _object; } public static JsonNode write(TopicPartitions _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topicId", new TextNode(_object.topicId.toString())); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.partitions) { _partitionsArray.add(new IntNode(_element)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicPartitions _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ConsumerProtocolAssignment.java
/* * 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.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Objects; 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.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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; public class ConsumerProtocolAssignment implements ApiMessage { TopicPartitionCollection assignedPartitions; ByteBuffer userData; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("assigned_partitions", new ArrayOf(TopicPartition.SCHEMA_0), ""), new Field("user_data", Type.NULLABLE_BYTES, "") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public ConsumerProtocolAssignment(Readable _readable, short _version) { read(_readable, _version); } public ConsumerProtocolAssignment() { this.assignedPartitions = new TopicPartitionCollection(0); this.userData = null; } @Override public short apiKey() { return -1; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field assignedPartitions 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."); } TopicPartitionCollection newCollection = new TopicPartitionCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicPartition(_readable, _version)); } this.assignedPartitions = newCollection; } } { int length; length = _readable.readInt(); if (length < 0) { this.userData = null; } else { this.userData = _readable.readByteBuffer(length); } } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; _writable.writeInt(assignedPartitions.size()); for (TopicPartition assignedPartitionsElement : assignedPartitions) { assignedPartitionsElement.write(_writable, _cache, _version); } if (userData == null) { _writable.writeInt(-1); } else { _writable.writeInt(userData.remaining()); _writable.writeByteBuffer(userData); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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(4); for (TopicPartition assignedPartitionsElement : assignedPartitions) { assignedPartitionsElement.addSize(_size, _cache, _version); } } if (userData == null) { _size.addBytes(4); } else { _size.addZeroCopyBytes(userData.remaining()); _size.addBytes(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()); } } 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 ConsumerProtocolAssignment)) return false; ConsumerProtocolAssignment other = (ConsumerProtocolAssignment) obj; if (this.assignedPartitions == null) { if (other.assignedPartitions != null) return false; } else { if (!this.assignedPartitions.equals(other.assignedPartitions)) return false; } if (!Objects.equals(this.userData, other.userData)) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (assignedPartitions == null ? 0 : assignedPartitions.hashCode()); hashCode = 31 * hashCode + Objects.hashCode(userData); return hashCode; } @Override public ConsumerProtocolAssignment duplicate() { ConsumerProtocolAssignment _duplicate = new ConsumerProtocolAssignment(); TopicPartitionCollection newAssignedPartitions = new TopicPartitionCollection(assignedPartitions.size()); for (TopicPartition _element : assignedPartitions) { newAssignedPartitions.add(_element.duplicate()); } _duplicate.assignedPartitions = newAssignedPartitions; if (userData == null) { _duplicate.userData = null; } else { _duplicate.userData = userData.duplicate(); } return _duplicate; } @Override public String toString() { return "ConsumerProtocolAssignment(" + "assignedPartitions=" + MessageUtil.deepToString(assignedPartitions.iterator()) + ", userData=" + userData + ")"; } public TopicPartitionCollection assignedPartitions() { return this.assignedPartitions; } public ByteBuffer userData() { return this.userData; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ConsumerProtocolAssignment setAssignedPartitions(TopicPartitionCollection v) { this.assignedPartitions = v; return this; } public ConsumerProtocolAssignment setUserData(ByteBuffer v) { this.userData = v; return this; } public static class TopicPartition implements Message, ImplicitLinkedHashMultiCollection.Element { String topic; List<Integer> partitions; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("topic", Type.STRING, ""), new Field("partitions", new ArrayOf(Type.INT32), "") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public TopicPartition(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public TopicPartition() { this.topic = ""; this.partitions = new ArrayList<Integer>(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicPartition"); } { int length; length = _readable.readShort(); if (length < 0) { throw new RuntimeException("non-nullable field topic was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topic had invalid length " + length); } else { this.topic = _readable.readString(length); } } { int arrayLength; arrayLength = _readable.readInt(); 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<Integer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(_readable.readInt()); } this.partitions = newCollection; } } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; { byte[] _stringBytes = _cache.getSerializedValue(topic); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } _writable.writeInt(partitions.size()); for (Integer partitionsElement : partitions) { _writable.writeInt(partitionsElement); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicPartition"); } { byte[] _stringBytes = topic.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'topic' field is too long to be serialized"); } _cache.cacheSerializedValue(topic, _stringBytes); _size.addBytes(_stringBytes.length + 2); } { _size.addBytes(4); _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()); } } if (_numTaggedFields > 0) { throw new UnsupportedVersionException("Tagged fields were set, but version " + _version + " of this message does not support them."); } } @Override public boolean elementKeysAreEqual(Object obj) { if (!(obj instanceof TopicPartition)) return false; TopicPartition other = (TopicPartition) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof TopicPartition)) return false; TopicPartition other = (TopicPartition) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) 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 + (topic == null ? 0 : topic.hashCode()); return hashCode; } @Override public TopicPartition duplicate() { TopicPartition _duplicate = new TopicPartition(); _duplicate.topic = topic; ArrayList<Integer> newPartitions = new ArrayList<Integer>(partitions.size()); for (Integer _element : partitions) { newPartitions.add(_element); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicPartition(" + "topic=" + ((topic == null) ? "null" : "'" + topic.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topic() { return this.topic; } public List<Integer> partitions() { return this.partitions; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicPartition setTopic(String v) { this.topic = v; return this; } public TopicPartition setPartitions(List<Integer> v) { this.partitions = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class TopicPartitionCollection extends ImplicitLinkedHashMultiCollection<TopicPartition> { public TopicPartitionCollection() { super(); } public TopicPartitionCollection(int expectedNumElements) { super(expectedNumElements); } public TopicPartitionCollection(Iterator<TopicPartition> iterator) { super(iterator); } public TopicPartition find(String topic) { TopicPartition _key = new TopicPartition(); _key.setTopic(topic); return find(_key); } public List<TopicPartition> findAll(String topic) { TopicPartition _key = new TopicPartition(); _key.setTopic(topic); return findAll(_key); } public TopicPartitionCollection duplicate() { TopicPartitionCollection _duplicate = new TopicPartitionCollection(size()); for (TopicPartition _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ConsumerProtocolAssignmentJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BinaryNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.nio.ByteBuffer; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.ConsumerProtocolAssignment.*; public class ConsumerProtocolAssignmentJsonConverter { public static ConsumerProtocolAssignment read(JsonNode _node, short _version) { ConsumerProtocolAssignment _object = new ConsumerProtocolAssignment(); JsonNode _assignedPartitionsNode = _node.get("assignedPartitions"); if (_assignedPartitionsNode == null) { throw new RuntimeException("ConsumerProtocolAssignment: unable to locate field 'assignedPartitions', which is mandatory in version " + _version); } else { if (!_assignedPartitionsNode.isArray()) { throw new RuntimeException("ConsumerProtocolAssignment expected a JSON array, but got " + _node.getNodeType()); } TopicPartitionCollection _collection = new TopicPartitionCollection(_assignedPartitionsNode.size()); _object.assignedPartitions = _collection; for (JsonNode _element : _assignedPartitionsNode) { _collection.add(TopicPartitionJsonConverter.read(_element, _version)); } } JsonNode _userDataNode = _node.get("userData"); if (_userDataNode == null) { throw new RuntimeException("ConsumerProtocolAssignment: unable to locate field 'userData', which is mandatory in version " + _version); } else { if (_userDataNode.isNull()) { _object.userData = null; } else { _object.userData = ByteBuffer.wrap(MessageUtil.jsonNodeToBinary(_userDataNode, "ConsumerProtocolAssignment")); } } return _object; } public static JsonNode write(ConsumerProtocolAssignment _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _assignedPartitionsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicPartition _element : _object.assignedPartitions) { _assignedPartitionsArray.add(TopicPartitionJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("assignedPartitions", _assignedPartitionsArray); if (_object.userData == null) { _node.set("userData", NullNode.instance); } else { _node.set("userData", new BinaryNode(MessageUtil.byteBufferToArray(_object.userData))); } return _node; } public static JsonNode write(ConsumerProtocolAssignment _object, short _version) { return write(_object, _version, true); } public static class TopicPartitionJsonConverter { public static TopicPartition read(JsonNode _node, short _version) { TopicPartition _object = new TopicPartition(); JsonNode _topicNode = _node.get("topic"); if (_topicNode == null) { throw new RuntimeException("TopicPartition: unable to locate field 'topic', which is mandatory in version " + _version); } else { if (!_topicNode.isTextual()) { throw new RuntimeException("TopicPartition expected a string type, but got " + _node.getNodeType()); } _object.topic = _topicNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicPartition: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicPartition expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "TopicPartition element")); } } return _object; } public static JsonNode write(TopicPartition _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topic", new TextNode(_object.topic)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.partitions) { _partitionsArray.add(new IntNode(_element)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicPartition _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ConsumerProtocolSubscription.java
/* * 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.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Objects; 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.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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; public class ConsumerProtocolSubscription implements ApiMessage { List<String> topics; ByteBuffer userData; TopicPartitionCollection ownedPartitions; int generationId; String rackId; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topics", new ArrayOf(Type.STRING), ""), new Field("user_data", Type.NULLABLE_BYTES, "") ); public static final Schema SCHEMA_1 = new Schema( new Field("topics", new ArrayOf(Type.STRING), ""), new Field("user_data", Type.NULLABLE_BYTES, ""), new Field("owned_partitions", new ArrayOf(TopicPartition.SCHEMA_1), "") ); public static final Schema SCHEMA_2 = new Schema( new Field("topics", new ArrayOf(Type.STRING), ""), new Field("user_data", Type.NULLABLE_BYTES, ""), new Field("owned_partitions", new ArrayOf(TopicPartition.SCHEMA_1), ""), new Field("generation_id", Type.INT32, "") ); public static final Schema SCHEMA_3 = new Schema( new Field("topics", new ArrayOf(Type.STRING), ""), new Field("user_data", Type.NULLABLE_BYTES, ""), new Field("owned_partitions", new ArrayOf(TopicPartition.SCHEMA_1), ""), new Field("generation_id", Type.INT32, ""), new Field("rack_id", Type.NULLABLE_STRING, "") ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public ConsumerProtocolSubscription(Readable _readable, short _version) { read(_readable, _version); } public ConsumerProtocolSubscription() { this.topics = new ArrayList<String>(0); this.userData = null; this.ownedPartitions = new TopicPartitionCollection(0); this.generationId = -1; this.rackId = null; } @Override public short apiKey() { return -1; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readShort(); if (length < 0) { throw new RuntimeException("non-nullable field topics element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topics element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.topics = newCollection; } } { int length; length = _readable.readInt(); if (length < 0) { this.userData = null; } else { this.userData = _readable.readByteBuffer(length); } } if (_version >= 1) { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field ownedPartitions 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."); } TopicPartitionCollection newCollection = new TopicPartitionCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicPartition(_readable, _version)); } this.ownedPartitions = newCollection; } } else { this.ownedPartitions = new TopicPartitionCollection(0); } if (_version >= 2) { this.generationId = _readable.readInt(); } else { this.generationId = -1; } if (_version >= 3) { int length; length = _readable.readShort(); if (length < 0) { this.rackId = null; } else if (length > 0x7fff) { throw new RuntimeException("string field rackId had invalid length " + length); } else { this.rackId = _readable.readString(length); } } else { this.rackId = null; } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; _writable.writeInt(topics.size()); for (String topicsElement : topics) { { byte[] _stringBytes = _cache.getSerializedValue(topicsElement); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } } if (userData == null) { _writable.writeInt(-1); } else { _writable.writeInt(userData.remaining()); _writable.writeByteBuffer(userData); } if (_version >= 1) { _writable.writeInt(ownedPartitions.size()); for (TopicPartition ownedPartitionsElement : ownedPartitions) { ownedPartitionsElement.write(_writable, _cache, _version); } } if (_version >= 2) { _writable.writeInt(generationId); } if (_version >= 3) { if (rackId == null) { _writable.writeShort((short) -1); } else { byte[] _stringBytes = _cache.getSerializedValue(rackId); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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(4); for (String topicsElement : topics) { byte[] _stringBytes = topicsElement.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'topicsElement' field is too long to be serialized"); } _cache.cacheSerializedValue(topicsElement, _stringBytes); _size.addBytes(_stringBytes.length + 2); } } if (userData == null) { _size.addBytes(4); } else { _size.addZeroCopyBytes(userData.remaining()); _size.addBytes(4); } if (_version >= 1) { { _size.addBytes(4); for (TopicPartition ownedPartitionsElement : ownedPartitions) { ownedPartitionsElement.addSize(_size, _cache, _version); } } } if (_version >= 2) { _size.addBytes(4); } if (_version >= 3) { if (rackId == null) { _size.addBytes(2); } else { byte[] _stringBytes = rackId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'rackId' field is too long to be serialized"); } _cache.cacheSerializedValue(rackId, _stringBytes); _size.addBytes(_stringBytes.length + 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 (_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 ConsumerProtocolSubscription)) return false; ConsumerProtocolSubscription other = (ConsumerProtocolSubscription) obj; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } if (!Objects.equals(this.userData, other.userData)) return false; if (this.ownedPartitions == null) { if (other.ownedPartitions != null) return false; } else { if (!this.ownedPartitions.equals(other.ownedPartitions)) return false; } if (generationId != other.generationId) return false; if (this.rackId == null) { if (other.rackId != null) return false; } else { if (!this.rackId.equals(other.rackId)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); hashCode = 31 * hashCode + Objects.hashCode(userData); hashCode = 31 * hashCode + (ownedPartitions == null ? 0 : ownedPartitions.hashCode()); hashCode = 31 * hashCode + generationId; hashCode = 31 * hashCode + (rackId == null ? 0 : rackId.hashCode()); return hashCode; } @Override public ConsumerProtocolSubscription duplicate() { ConsumerProtocolSubscription _duplicate = new ConsumerProtocolSubscription(); ArrayList<String> newTopics = new ArrayList<String>(topics.size()); for (String _element : topics) { newTopics.add(_element); } _duplicate.topics = newTopics; if (userData == null) { _duplicate.userData = null; } else { _duplicate.userData = userData.duplicate(); } TopicPartitionCollection newOwnedPartitions = new TopicPartitionCollection(ownedPartitions.size()); for (TopicPartition _element : ownedPartitions) { newOwnedPartitions.add(_element.duplicate()); } _duplicate.ownedPartitions = newOwnedPartitions; _duplicate.generationId = generationId; if (rackId == null) { _duplicate.rackId = null; } else { _duplicate.rackId = rackId; } return _duplicate; } @Override public String toString() { return "ConsumerProtocolSubscription(" + "topics=" + MessageUtil.deepToString(topics.iterator()) + ", userData=" + userData + ", ownedPartitions=" + MessageUtil.deepToString(ownedPartitions.iterator()) + ", generationId=" + generationId + ", rackId=" + ((rackId == null) ? "null" : "'" + rackId.toString() + "'") + ")"; } public List<String> topics() { return this.topics; } public ByteBuffer userData() { return this.userData; } public TopicPartitionCollection ownedPartitions() { return this.ownedPartitions; } public int generationId() { return this.generationId; } public String rackId() { return this.rackId; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ConsumerProtocolSubscription setTopics(List<String> v) { this.topics = v; return this; } public ConsumerProtocolSubscription setUserData(ByteBuffer v) { this.userData = v; return this; } public ConsumerProtocolSubscription setOwnedPartitions(TopicPartitionCollection v) { this.ownedPartitions = v; return this; } public ConsumerProtocolSubscription setGenerationId(int v) { this.generationId = v; return this; } public ConsumerProtocolSubscription setRackId(String v) { this.rackId = v; return this; } public static class TopicPartition implements Message, ImplicitLinkedHashMultiCollection.Element { String topic; List<Integer> partitions; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_1 = new Schema( new Field("topic", Type.STRING, ""), new Field("partitions", new ArrayOf(Type.INT32), "") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { null, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 1; public static final short HIGHEST_SUPPORTED_VERSION = 3; public TopicPartition(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public TopicPartition() { this.topic = ""; this.partitions = new ArrayList<Integer>(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicPartition"); } { int length; length = _readable.readShort(); if (length < 0) { throw new RuntimeException("non-nullable field topic was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topic had invalid length " + length); } else { this.topic = _readable.readString(length); } } { int arrayLength; arrayLength = _readable.readInt(); 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<Integer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(_readable.readInt()); } this.partitions = newCollection; } } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { if (_version < 1) { throw new UnsupportedVersionException("Can't write version " + _version + " of TopicPartition"); } int _numTaggedFields = 0; { byte[] _stringBytes = _cache.getSerializedValue(topic); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } _writable.writeInt(partitions.size()); for (Integer partitionsElement : partitions) { _writable.writeInt(partitionsElement); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicPartition"); } { byte[] _stringBytes = topic.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'topic' field is too long to be serialized"); } _cache.cacheSerializedValue(topic, _stringBytes); _size.addBytes(_stringBytes.length + 2); } { _size.addBytes(4); _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()); } } if (_numTaggedFields > 0) { throw new UnsupportedVersionException("Tagged fields were set, but version " + _version + " of this message does not support them."); } } @Override public boolean elementKeysAreEqual(Object obj) { if (!(obj instanceof TopicPartition)) return false; TopicPartition other = (TopicPartition) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof TopicPartition)) return false; TopicPartition other = (TopicPartition) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) 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 + (topic == null ? 0 : topic.hashCode()); return hashCode; } @Override public TopicPartition duplicate() { TopicPartition _duplicate = new TopicPartition(); _duplicate.topic = topic; ArrayList<Integer> newPartitions = new ArrayList<Integer>(partitions.size()); for (Integer _element : partitions) { newPartitions.add(_element); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicPartition(" + "topic=" + ((topic == null) ? "null" : "'" + topic.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topic() { return this.topic; } public List<Integer> partitions() { return this.partitions; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicPartition setTopic(String v) { this.topic = v; return this; } public TopicPartition setPartitions(List<Integer> v) { this.partitions = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class TopicPartitionCollection extends ImplicitLinkedHashMultiCollection<TopicPartition> { public TopicPartitionCollection() { super(); } public TopicPartitionCollection(int expectedNumElements) { super(expectedNumElements); } public TopicPartitionCollection(Iterator<TopicPartition> iterator) { super(iterator); } public TopicPartition find(String topic) { TopicPartition _key = new TopicPartition(); _key.setTopic(topic); return find(_key); } public List<TopicPartition> findAll(String topic) { TopicPartition _key = new TopicPartition(); _key.setTopic(topic); return findAll(_key); } public TopicPartitionCollection duplicate() { TopicPartitionCollection _duplicate = new TopicPartitionCollection(size()); for (TopicPartition _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ConsumerProtocolSubscriptionJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BinaryNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.nio.ByteBuffer; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.ConsumerProtocolSubscription.*; public class ConsumerProtocolSubscriptionJsonConverter { public static ConsumerProtocolSubscription read(JsonNode _node, short _version) { ConsumerProtocolSubscription _object = new ConsumerProtocolSubscription(); JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("ConsumerProtocolSubscription: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("ConsumerProtocolSubscription expected a JSON array, but got " + _node.getNodeType()); } ArrayList<String> _collection = new ArrayList<String>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { if (!_element.isTextual()) { throw new RuntimeException("ConsumerProtocolSubscription element expected a string type, but got " + _node.getNodeType()); } _collection.add(_element.asText()); } } JsonNode _userDataNode = _node.get("userData"); if (_userDataNode == null) { throw new RuntimeException("ConsumerProtocolSubscription: unable to locate field 'userData', which is mandatory in version " + _version); } else { if (_userDataNode.isNull()) { _object.userData = null; } else { _object.userData = ByteBuffer.wrap(MessageUtil.jsonNodeToBinary(_userDataNode, "ConsumerProtocolSubscription")); } } JsonNode _ownedPartitionsNode = _node.get("ownedPartitions"); if (_ownedPartitionsNode == null) { if (_version >= 1) { throw new RuntimeException("ConsumerProtocolSubscription: unable to locate field 'ownedPartitions', which is mandatory in version " + _version); } else { _object.ownedPartitions = new TopicPartitionCollection(0); } } else { if (!_ownedPartitionsNode.isArray()) { throw new RuntimeException("ConsumerProtocolSubscription expected a JSON array, but got " + _node.getNodeType()); } TopicPartitionCollection _collection = new TopicPartitionCollection(_ownedPartitionsNode.size()); _object.ownedPartitions = _collection; for (JsonNode _element : _ownedPartitionsNode) { _collection.add(TopicPartitionJsonConverter.read(_element, _version)); } } JsonNode _generationIdNode = _node.get("generationId"); if (_generationIdNode == null) { if (_version >= 2) { throw new RuntimeException("ConsumerProtocolSubscription: unable to locate field 'generationId', which is mandatory in version " + _version); } else { _object.generationId = -1; } } else { _object.generationId = MessageUtil.jsonNodeToInt(_generationIdNode, "ConsumerProtocolSubscription"); } JsonNode _rackIdNode = _node.get("rackId"); if (_rackIdNode == null) { if (_version >= 3) { throw new RuntimeException("ConsumerProtocolSubscription: unable to locate field 'rackId', which is mandatory in version " + _version); } else { _object.rackId = null; } } else { if (_rackIdNode.isNull()) { _object.rackId = null; } else { if (!_rackIdNode.isTextual()) { throw new RuntimeException("ConsumerProtocolSubscription expected a string type, but got " + _node.getNodeType()); } _object.rackId = _rackIdNode.asText(); } } return _object; } public static JsonNode write(ConsumerProtocolSubscription _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (String _element : _object.topics) { _topicsArray.add(new TextNode(_element)); } _node.set("topics", _topicsArray); if (_object.userData == null) { _node.set("userData", NullNode.instance); } else { _node.set("userData", new BinaryNode(MessageUtil.byteBufferToArray(_object.userData))); } if (_version >= 1) { ArrayNode _ownedPartitionsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicPartition _element : _object.ownedPartitions) { _ownedPartitionsArray.add(TopicPartitionJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("ownedPartitions", _ownedPartitionsArray); } if (_version >= 2) { _node.set("generationId", new IntNode(_object.generationId)); } if (_version >= 3) { if (_object.rackId == null) { _node.set("rackId", NullNode.instance); } else { _node.set("rackId", new TextNode(_object.rackId)); } } return _node; } public static JsonNode write(ConsumerProtocolSubscription _object, short _version) { return write(_object, _version, true); } public static class TopicPartitionJsonConverter { public static TopicPartition read(JsonNode _node, short _version) { TopicPartition _object = new TopicPartition(); if (_version < 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicPartition"); } JsonNode _topicNode = _node.get("topic"); if (_topicNode == null) { throw new RuntimeException("TopicPartition: unable to locate field 'topic', which is mandatory in version " + _version); } else { if (!_topicNode.isTextual()) { throw new RuntimeException("TopicPartition expected a string type, but got " + _node.getNodeType()); } _object.topic = _topicNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicPartition: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicPartition expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "TopicPartition element")); } } return _object; } public static JsonNode write(TopicPartition _object, short _version, boolean _serializeRecords) { if (_version < 1) { throw new UnsupportedVersionException("Can't write version " + _version + " of TopicPartition"); } ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topic", new TextNode(_object.topic)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.partitions) { _partitionsArray.add(new IntNode(_element)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicPartition _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ControlledShutdownRequestData.java
/* * 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.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.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.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 ControlledShutdownRequestData implements ApiMessage { int brokerId; long brokerEpoch; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("broker_id", Type.INT32, "The id of the broker for which controlled shutdown has been requested.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("broker_id", Type.INT32, "The id of the broker for which controlled shutdown has been requested."), new Field("broker_epoch", Type.INT64, "The broker epoch.") ); public static final Schema SCHEMA_3 = new Schema( new Field("broker_id", Type.INT32, "The id of the broker for which controlled shutdown has been requested."), new Field("broker_epoch", Type.INT64, "The broker epoch."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public ControlledShutdownRequestData(Readable _readable, short _version) { read(_readable, _version); } public ControlledShutdownRequestData() { this.brokerId = 0; this.brokerEpoch = -1L; } @Override public short apiKey() { return 7; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { this.brokerId = _readable.readInt(); if (_version >= 2) { this.brokerEpoch = _readable.readLong(); } else { this.brokerEpoch = -1L; } this._unknownTaggedFields = null; if (_version >= 3) { 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(brokerId); if (_version >= 2) { _writable.writeLong(brokerEpoch); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 3) { _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(4); if (_version >= 2) { _size.addBytes(8); } 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 >= 3) { _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 ControlledShutdownRequestData)) return false; ControlledShutdownRequestData other = (ControlledShutdownRequestData) obj; if (brokerId != other.brokerId) return false; if (brokerEpoch != other.brokerEpoch) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + brokerId; hashCode = 31 * hashCode + ((int) (brokerEpoch >> 32) ^ (int) brokerEpoch); return hashCode; } @Override public ControlledShutdownRequestData duplicate() { ControlledShutdownRequestData _duplicate = new ControlledShutdownRequestData(); _duplicate.brokerId = brokerId; _duplicate.brokerEpoch = brokerEpoch; return _duplicate; } @Override public String toString() { return "ControlledShutdownRequestData(" + "brokerId=" + brokerId + ", brokerEpoch=" + brokerEpoch + ")"; } public int brokerId() { return this.brokerId; } public long brokerEpoch() { return this.brokerEpoch; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ControlledShutdownRequestData setBrokerId(int v) { this.brokerId = v; return this; } public ControlledShutdownRequestData setBrokerEpoch(long v) { this.brokerEpoch = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ControlledShutdownRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.ControlledShutdownRequestData.*; public class ControlledShutdownRequestDataJsonConverter { public static ControlledShutdownRequestData read(JsonNode _node, short _version) { ControlledShutdownRequestData _object = new ControlledShutdownRequestData(); JsonNode _brokerIdNode = _node.get("brokerId"); if (_brokerIdNode == null) { throw new RuntimeException("ControlledShutdownRequestData: unable to locate field 'brokerId', which is mandatory in version " + _version); } else { _object.brokerId = MessageUtil.jsonNodeToInt(_brokerIdNode, "ControlledShutdownRequestData"); } JsonNode _brokerEpochNode = _node.get("brokerEpoch"); if (_brokerEpochNode == null) { if (_version >= 2) { throw new RuntimeException("ControlledShutdownRequestData: unable to locate field 'brokerEpoch', which is mandatory in version " + _version); } else { _object.brokerEpoch = -1L; } } else { _object.brokerEpoch = MessageUtil.jsonNodeToLong(_brokerEpochNode, "ControlledShutdownRequestData"); } return _object; } public static JsonNode write(ControlledShutdownRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("brokerId", new IntNode(_object.brokerId)); if (_version >= 2) { _node.set("brokerEpoch", new LongNode(_object.brokerEpoch)); } return _node; } public static JsonNode write(ControlledShutdownRequestData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ControlledShutdownResponseData.java
/* * 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.Iterator; 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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class ControlledShutdownResponseData implements ApiMessage { short errorCode; RemainingPartitionCollection remainingPartitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The top-level error code."), new Field("remaining_partitions", new ArrayOf(RemainingPartition.SCHEMA_0), "The partitions that the broker still leads.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = new Schema( new Field("error_code", Type.INT16, "The top-level error code."), new Field("remaining_partitions", new CompactArrayOf(RemainingPartition.SCHEMA_3), "The partitions that the broker still leads."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public ControlledShutdownResponseData(Readable _readable, short _version) { read(_readable, _version); } public ControlledShutdownResponseData() { this.errorCode = (short) 0; this.remainingPartitions = new RemainingPartitionCollection(0); } @Override public short apiKey() { return 7; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { this.errorCode = _readable.readShort(); { if (_version >= 3) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field remainingPartitions 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."); } RemainingPartitionCollection newCollection = new RemainingPartitionCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new RemainingPartition(_readable, _version)); } this.remainingPartitions = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field remainingPartitions 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."); } RemainingPartitionCollection newCollection = new RemainingPartitionCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new RemainingPartition(_readable, _version)); } this.remainingPartitions = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 3) { 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 >= 3) { _writable.writeUnsignedVarint(remainingPartitions.size() + 1); for (RemainingPartition remainingPartitionsElement : remainingPartitions) { remainingPartitionsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(remainingPartitions.size()); for (RemainingPartition remainingPartitionsElement : remainingPartitions) { remainingPartitionsElement.write(_writable, _cache, _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 3) { _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 >= 3) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(remainingPartitions.size() + 1)); } else { _size.addBytes(4); } for (RemainingPartition remainingPartitionsElement : remainingPartitions) { remainingPartitionsElement.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 >= 3) { _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 ControlledShutdownResponseData)) return false; ControlledShutdownResponseData other = (ControlledShutdownResponseData) obj; if (errorCode != other.errorCode) return false; if (this.remainingPartitions == null) { if (other.remainingPartitions != null) return false; } else { if (!this.remainingPartitions.equals(other.remainingPartitions)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (remainingPartitions == null ? 0 : remainingPartitions.hashCode()); return hashCode; } @Override public ControlledShutdownResponseData duplicate() { ControlledShutdownResponseData _duplicate = new ControlledShutdownResponseData(); _duplicate.errorCode = errorCode; RemainingPartitionCollection newRemainingPartitions = new RemainingPartitionCollection(remainingPartitions.size()); for (RemainingPartition _element : remainingPartitions) { newRemainingPartitions.add(_element.duplicate()); } _duplicate.remainingPartitions = newRemainingPartitions; return _duplicate; } @Override public String toString() { return "ControlledShutdownResponseData(" + "errorCode=" + errorCode + ", remainingPartitions=" + MessageUtil.deepToString(remainingPartitions.iterator()) + ")"; } public short errorCode() { return this.errorCode; } public RemainingPartitionCollection remainingPartitions() { return this.remainingPartitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ControlledShutdownResponseData setErrorCode(short v) { this.errorCode = v; return this; } public ControlledShutdownResponseData setRemainingPartitions(RemainingPartitionCollection v) { this.remainingPartitions = v; return this; } public static class RemainingPartition implements Message, ImplicitLinkedHashMultiCollection.Element { String topicName; int partitionIndex; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("topic_name", Type.STRING, "The name of the topic."), new Field("partition_index", Type.INT32, "The index of the partition.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = new Schema( new Field("topic_name", Type.COMPACT_STRING, "The name of the topic."), new Field("partition_index", Type.INT32, "The index of the partition."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public RemainingPartition(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public RemainingPartition() { this.topicName = ""; this.partitionIndex = 0; this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of RemainingPartition"); } { int length; if (_version >= 3) { 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._unknownTaggedFields = null; if (_version >= 3) { 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 >= 3) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeInt(partitionIndex); RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 3) { _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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of RemainingPartition"); } { 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 >= 3) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(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()); } } if (_version >= 3) { _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof RemainingPartition)) return false; RemainingPartition other = (RemainingPartition) 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; return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof RemainingPartition)) return false; RemainingPartition other = (RemainingPartition) 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; 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; return hashCode; } @Override public RemainingPartition duplicate() { RemainingPartition _duplicate = new RemainingPartition(); _duplicate.topicName = topicName; _duplicate.partitionIndex = partitionIndex; return _duplicate; } @Override public String toString() { return "RemainingPartition(" + "topicName=" + ((topicName == null) ? "null" : "'" + topicName.toString() + "'") + ", partitionIndex=" + partitionIndex + ")"; } public String topicName() { return this.topicName; } public int partitionIndex() { return this.partitionIndex; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public RemainingPartition setTopicName(String v) { this.topicName = v; return this; } public RemainingPartition setPartitionIndex(int v) { this.partitionIndex = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class RemainingPartitionCollection extends ImplicitLinkedHashMultiCollection<RemainingPartition> { public RemainingPartitionCollection() { super(); } public RemainingPartitionCollection(int expectedNumElements) { super(expectedNumElements); } public RemainingPartitionCollection(Iterator<RemainingPartition> iterator) { super(iterator); } public RemainingPartition find(String topicName, int partitionIndex) { RemainingPartition _key = new RemainingPartition(); _key.setTopicName(topicName); _key.setPartitionIndex(partitionIndex); return find(_key); } public List<RemainingPartition> findAll(String topicName, int partitionIndex) { RemainingPartition _key = new RemainingPartition(); _key.setTopicName(topicName); _key.setPartitionIndex(partitionIndex); return findAll(_key); } public RemainingPartitionCollection duplicate() { RemainingPartitionCollection _duplicate = new RemainingPartitionCollection(size()); for (RemainingPartition _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ControlledShutdownResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.ControlledShutdownResponseData.*; public class ControlledShutdownResponseDataJsonConverter { public static ControlledShutdownResponseData read(JsonNode _node, short _version) { ControlledShutdownResponseData _object = new ControlledShutdownResponseData(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("ControlledShutdownResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "ControlledShutdownResponseData"); } JsonNode _remainingPartitionsNode = _node.get("remainingPartitions"); if (_remainingPartitionsNode == null) { throw new RuntimeException("ControlledShutdownResponseData: unable to locate field 'remainingPartitions', which is mandatory in version " + _version); } else { if (!_remainingPartitionsNode.isArray()) { throw new RuntimeException("ControlledShutdownResponseData expected a JSON array, but got " + _node.getNodeType()); } RemainingPartitionCollection _collection = new RemainingPartitionCollection(_remainingPartitionsNode.size()); _object.remainingPartitions = _collection; for (JsonNode _element : _remainingPartitionsNode) { _collection.add(RemainingPartitionJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(ControlledShutdownResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); ArrayNode _remainingPartitionsArray = new ArrayNode(JsonNodeFactory.instance); for (RemainingPartition _element : _object.remainingPartitions) { _remainingPartitionsArray.add(RemainingPartitionJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("remainingPartitions", _remainingPartitionsArray); return _node; } public static JsonNode write(ControlledShutdownResponseData _object, short _version) { return write(_object, _version, true); } public static class RemainingPartitionJsonConverter { public static RemainingPartition read(JsonNode _node, short _version) { RemainingPartition _object = new RemainingPartition(); JsonNode _topicNameNode = _node.get("topicName"); if (_topicNameNode == null) { throw new RuntimeException("RemainingPartition: unable to locate field 'topicName', which is mandatory in version " + _version); } else { if (!_topicNameNode.isTextual()) { throw new RuntimeException("RemainingPartition expected a string type, but got " + _node.getNodeType()); } _object.topicName = _topicNameNode.asText(); } JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("RemainingPartition: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "RemainingPartition"); } return _object; } public static JsonNode write(RemainingPartition _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topicName", new TextNode(_object.topicName)); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); return _node; } public static JsonNode write(RemainingPartition _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateAclsRequestData.java
/* * 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 CreateAclsRequestData implements ApiMessage { List<AclCreation> creations; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("creations", new ArrayOf(AclCreation.SCHEMA_0), "The ACLs that we want to create.") ); public static final Schema SCHEMA_1 = new Schema( new Field("creations", new ArrayOf(AclCreation.SCHEMA_1), "The ACLs that we want to create.") ); public static final Schema SCHEMA_2 = new Schema( new Field("creations", new CompactArrayOf(AclCreation.SCHEMA_2), "The ACLs that we want to create."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreateAclsRequestData(Readable _readable, short _version) { read(_readable, _version); } public CreateAclsRequestData() { this.creations = new ArrayList<AclCreation>(0); } @Override public short apiKey() { return 30; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field creations 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<AclCreation> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new AclCreation(_readable, _version)); } this.creations = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field creations 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<AclCreation> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new AclCreation(_readable, _version)); } this.creations = 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; if (_version >= 2) { _writable.writeUnsignedVarint(creations.size() + 1); for (AclCreation creationsElement : creations) { creationsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(creations.size()); for (AclCreation creationsElement : creations) { creationsElement.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; { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(creations.size() + 1)); } else { _size.addBytes(4); } for (AclCreation creationsElement : creations) { creationsElement.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 CreateAclsRequestData)) return false; CreateAclsRequestData other = (CreateAclsRequestData) obj; if (this.creations == null) { if (other.creations != null) return false; } else { if (!this.creations.equals(other.creations)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (creations == null ? 0 : creations.hashCode()); return hashCode; } @Override public CreateAclsRequestData duplicate() { CreateAclsRequestData _duplicate = new CreateAclsRequestData(); ArrayList<AclCreation> newCreations = new ArrayList<AclCreation>(creations.size()); for (AclCreation _element : creations) { newCreations.add(_element.duplicate()); } _duplicate.creations = newCreations; return _duplicate; } @Override public String toString() { return "CreateAclsRequestData(" + "creations=" + MessageUtil.deepToString(creations.iterator()) + ")"; } public List<AclCreation> creations() { return this.creations; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreateAclsRequestData setCreations(List<AclCreation> v) { this.creations = v; return this; } public static class AclCreation implements Message { byte resourceType; String resourceName; byte resourcePatternType; String principal; String host; byte operation; byte permissionType; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("resource_type", Type.INT8, "The type of the resource."), new Field("resource_name", Type.STRING, "The resource name for the ACL."), new Field("principal", Type.STRING, "The principal for the ACL."), new Field("host", Type.STRING, "The host for the ACL."), new Field("operation", Type.INT8, "The operation type for the ACL (read, write, etc.)."), new Field("permission_type", Type.INT8, "The permission type for the ACL (allow, deny, etc.).") ); public static final Schema SCHEMA_1 = new Schema( new Field("resource_type", Type.INT8, "The type of the resource."), new Field("resource_name", Type.STRING, "The resource name for the ACL."), new Field("resource_pattern_type", Type.INT8, "The pattern type for the ACL."), new Field("principal", Type.STRING, "The principal for the ACL."), new Field("host", Type.STRING, "The host for the ACL."), new Field("operation", Type.INT8, "The operation type for the ACL (read, write, etc.)."), new Field("permission_type", Type.INT8, "The permission type for the ACL (allow, deny, etc.).") ); public static final Schema SCHEMA_2 = new Schema( new Field("resource_type", Type.INT8, "The type of the resource."), new Field("resource_name", Type.COMPACT_STRING, "The resource name for the ACL."), new Field("resource_pattern_type", Type.INT8, "The pattern type for the ACL."), new Field("principal", Type.COMPACT_STRING, "The principal for the ACL."), new Field("host", Type.COMPACT_STRING, "The host for the ACL."), new Field("operation", Type.INT8, "The operation type for the ACL (read, write, etc.)."), new Field("permission_type", Type.INT8, "The permission type for the ACL (allow, deny, etc.)."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public AclCreation(Readable _readable, short _version) { read(_readable, _version); } public AclCreation() { this.resourceType = (byte) 0; this.resourceName = ""; this.resourcePatternType = (byte) 3; this.principal = ""; this.host = ""; this.operation = (byte) 0; this.permissionType = (byte) 0; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of AclCreation"); } this.resourceType = _readable.readByte(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field resourceName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field resourceName had invalid length " + length); } else { this.resourceName = _readable.readString(length); } } if (_version >= 1) { this.resourcePatternType = _readable.readByte(); } else { this.resourcePatternType = (byte) 3; } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principal was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principal had invalid length " + length); } else { this.principal = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field host was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field host had invalid length " + length); } else { this.host = _readable.readString(length); } } this.operation = _readable.readByte(); this.permissionType = _readable.readByte(); 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.writeByte(resourceType); { byte[] _stringBytes = _cache.getSerializedValue(resourceName); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 1) { _writable.writeByte(resourcePatternType); } else { if (this.resourcePatternType != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default resourcePatternType at version " + _version); } } { byte[] _stringBytes = _cache.getSerializedValue(principal); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(host); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(operation); _writable.writeByte(permissionType); 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of AclCreation"); } _size.addBytes(1); { byte[] _stringBytes = resourceName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'resourceName' field is too long to be serialized"); } _cache.cacheSerializedValue(resourceName, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 1) { _size.addBytes(1); } { byte[] _stringBytes = principal.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principal' field is too long to be serialized"); } _cache.cacheSerializedValue(principal, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = host.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'host' field is too long to be serialized"); } _cache.cacheSerializedValue(host, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); _size.addBytes(1); 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 AclCreation)) return false; AclCreation other = (AclCreation) obj; if (resourceType != other.resourceType) return false; if (this.resourceName == null) { if (other.resourceName != null) return false; } else { if (!this.resourceName.equals(other.resourceName)) return false; } if (resourcePatternType != other.resourcePatternType) return false; if (this.principal == null) { if (other.principal != null) return false; } else { if (!this.principal.equals(other.principal)) return false; } if (this.host == null) { if (other.host != null) return false; } else { if (!this.host.equals(other.host)) return false; } if (operation != other.operation) return false; if (permissionType != other.permissionType) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + resourceType; hashCode = 31 * hashCode + (resourceName == null ? 0 : resourceName.hashCode()); hashCode = 31 * hashCode + resourcePatternType; hashCode = 31 * hashCode + (principal == null ? 0 : principal.hashCode()); hashCode = 31 * hashCode + (host == null ? 0 : host.hashCode()); hashCode = 31 * hashCode + operation; hashCode = 31 * hashCode + permissionType; return hashCode; } @Override public AclCreation duplicate() { AclCreation _duplicate = new AclCreation(); _duplicate.resourceType = resourceType; _duplicate.resourceName = resourceName; _duplicate.resourcePatternType = resourcePatternType; _duplicate.principal = principal; _duplicate.host = host; _duplicate.operation = operation; _duplicate.permissionType = permissionType; return _duplicate; } @Override public String toString() { return "AclCreation(" + "resourceType=" + resourceType + ", resourceName=" + ((resourceName == null) ? "null" : "'" + resourceName.toString() + "'") + ", resourcePatternType=" + resourcePatternType + ", principal=" + ((principal == null) ? "null" : "'" + principal.toString() + "'") + ", host=" + ((host == null) ? "null" : "'" + host.toString() + "'") + ", operation=" + operation + ", permissionType=" + permissionType + ")"; } public byte resourceType() { return this.resourceType; } public String resourceName() { return this.resourceName; } public byte resourcePatternType() { return this.resourcePatternType; } public String principal() { return this.principal; } public String host() { return this.host; } public byte operation() { return this.operation; } public byte permissionType() { return this.permissionType; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public AclCreation setResourceType(byte v) { this.resourceType = v; return this; } public AclCreation setResourceName(String v) { this.resourceName = v; return this; } public AclCreation setResourcePatternType(byte v) { this.resourcePatternType = v; return this; } public AclCreation setPrincipal(String v) { this.principal = v; return this; } public AclCreation setHost(String v) { this.host = v; return this; } public AclCreation setOperation(byte v) { this.operation = v; return this; } public AclCreation setPermissionType(byte v) { this.permissionType = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateAclsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.CreateAclsRequestData.*; public class CreateAclsRequestDataJsonConverter { public static CreateAclsRequestData read(JsonNode _node, short _version) { CreateAclsRequestData _object = new CreateAclsRequestData(); JsonNode _creationsNode = _node.get("creations"); if (_creationsNode == null) { throw new RuntimeException("CreateAclsRequestData: unable to locate field 'creations', which is mandatory in version " + _version); } else { if (!_creationsNode.isArray()) { throw new RuntimeException("CreateAclsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<AclCreation> _collection = new ArrayList<AclCreation>(_creationsNode.size()); _object.creations = _collection; for (JsonNode _element : _creationsNode) { _collection.add(AclCreationJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(CreateAclsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _creationsArray = new ArrayNode(JsonNodeFactory.instance); for (AclCreation _element : _object.creations) { _creationsArray.add(AclCreationJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("creations", _creationsArray); return _node; } public static JsonNode write(CreateAclsRequestData _object, short _version) { return write(_object, _version, true); } public static class AclCreationJsonConverter { public static AclCreation read(JsonNode _node, short _version) { AclCreation _object = new AclCreation(); JsonNode _resourceTypeNode = _node.get("resourceType"); if (_resourceTypeNode == null) { throw new RuntimeException("AclCreation: unable to locate field 'resourceType', which is mandatory in version " + _version); } else { _object.resourceType = MessageUtil.jsonNodeToByte(_resourceTypeNode, "AclCreation"); } JsonNode _resourceNameNode = _node.get("resourceName"); if (_resourceNameNode == null) { throw new RuntimeException("AclCreation: unable to locate field 'resourceName', which is mandatory in version " + _version); } else { if (!_resourceNameNode.isTextual()) { throw new RuntimeException("AclCreation expected a string type, but got " + _node.getNodeType()); } _object.resourceName = _resourceNameNode.asText(); } JsonNode _resourcePatternTypeNode = _node.get("resourcePatternType"); if (_resourcePatternTypeNode == null) { if (_version >= 1) { throw new RuntimeException("AclCreation: unable to locate field 'resourcePatternType', which is mandatory in version " + _version); } else { _object.resourcePatternType = (byte) 3; } } else { _object.resourcePatternType = MessageUtil.jsonNodeToByte(_resourcePatternTypeNode, "AclCreation"); } JsonNode _principalNode = _node.get("principal"); if (_principalNode == null) { throw new RuntimeException("AclCreation: unable to locate field 'principal', which is mandatory in version " + _version); } else { if (!_principalNode.isTextual()) { throw new RuntimeException("AclCreation expected a string type, but got " + _node.getNodeType()); } _object.principal = _principalNode.asText(); } JsonNode _hostNode = _node.get("host"); if (_hostNode == null) { throw new RuntimeException("AclCreation: unable to locate field 'host', which is mandatory in version " + _version); } else { if (!_hostNode.isTextual()) { throw new RuntimeException("AclCreation expected a string type, but got " + _node.getNodeType()); } _object.host = _hostNode.asText(); } JsonNode _operationNode = _node.get("operation"); if (_operationNode == null) { throw new RuntimeException("AclCreation: unable to locate field 'operation', which is mandatory in version " + _version); } else { _object.operation = MessageUtil.jsonNodeToByte(_operationNode, "AclCreation"); } JsonNode _permissionTypeNode = _node.get("permissionType"); if (_permissionTypeNode == null) { throw new RuntimeException("AclCreation: unable to locate field 'permissionType', which is mandatory in version " + _version); } else { _object.permissionType = MessageUtil.jsonNodeToByte(_permissionTypeNode, "AclCreation"); } return _object; } public static JsonNode write(AclCreation _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("resourceType", new ShortNode(_object.resourceType)); _node.set("resourceName", new TextNode(_object.resourceName)); if (_version >= 1) { _node.set("resourcePatternType", new ShortNode(_object.resourcePatternType)); } else { if (_object.resourcePatternType != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default resourcePatternType at version " + _version); } } _node.set("principal", new TextNode(_object.principal)); _node.set("host", new TextNode(_object.host)); _node.set("operation", new ShortNode(_object.operation)); _node.set("permissionType", new ShortNode(_object.permissionType)); return _node; } public static JsonNode write(AclCreation _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateAclsResponseData.java
/* * 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 CreateAclsResponseData implements ApiMessage { int throttleTimeMs; List<AclCreationResult> results; private List<RawTaggedField> _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("results", new ArrayOf(AclCreationResult.SCHEMA_0), "The results for each ACL creation.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = 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("results", new CompactArrayOf(AclCreationResult.SCHEMA_2), "The results for each ACL creation."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreateAclsResponseData(Readable _readable, short _version) { read(_readable, _version); } public CreateAclsResponseData() { this.throttleTimeMs = 0; this.results = new ArrayList<AclCreationResult>(0); } @Override public short apiKey() { return 30; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<AclCreationResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new AclCreationResult(_readable, _version)); } this.results = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<AclCreationResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new AclCreationResult(_readable, _version)); } this.results = 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.writeInt(throttleTimeMs); if (_version >= 2) { _writable.writeUnsignedVarint(results.size() + 1); for (AclCreationResult resultsElement : results) { resultsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(results.size()); for (AclCreationResult resultsElement : results) { resultsElement.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(4); { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(results.size() + 1)); } else { _size.addBytes(4); } for (AclCreationResult resultsElement : results) { resultsElement.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 CreateAclsResponseData)) return false; CreateAclsResponseData other = (CreateAclsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.results == null) { if (other.results != null) return false; } else { if (!this.results.equals(other.results)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (results == null ? 0 : results.hashCode()); return hashCode; } @Override public CreateAclsResponseData duplicate() { CreateAclsResponseData _duplicate = new CreateAclsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; ArrayList<AclCreationResult> newResults = new ArrayList<AclCreationResult>(results.size()); for (AclCreationResult _element : results) { newResults.add(_element.duplicate()); } _duplicate.results = newResults; return _duplicate; } @Override public String toString() { return "CreateAclsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", results=" + MessageUtil.deepToString(results.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public List<AclCreationResult> results() { return this.results; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreateAclsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public CreateAclsResponseData setResults(List<AclCreationResult> v) { this.results = v; return this; } public static class AclCreationResult implements Message { short errorCode; String errorMessage; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The result error, or zero if there was no error."), new Field("error_message", Type.NULLABLE_STRING, "The result message, or null if there was no error.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("error_code", Type.INT16, "The result error, or zero if there was no error."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The result message, or null if there was no error."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public AclCreationResult(Readable _readable, short _version) { read(_readable, _version); } public AclCreationResult() { this.errorCode = (short) 0; this.errorMessage = ""; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of AclCreationResult"); } this.errorCode = _readable.readShort(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } 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 (errorMessage == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of AclCreationResult"); } _size.addBytes(2); if (errorMessage == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 AclCreationResult)) return false; AclCreationResult other = (AclCreationResult) obj; 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; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode()); return hashCode; } @Override public AclCreationResult duplicate() { AclCreationResult _duplicate = new AclCreationResult(); _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } return _duplicate; } @Override public String toString() { return "AclCreationResult(" + "errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ")"; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public AclCreationResult setErrorCode(short v) { this.errorCode = v; return this; } public AclCreationResult setErrorMessage(String v) { this.errorMessage = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateAclsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.CreateAclsResponseData.*; public class CreateAclsResponseDataJsonConverter { public static CreateAclsResponseData read(JsonNode _node, short _version) { CreateAclsResponseData _object = new CreateAclsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("CreateAclsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "CreateAclsResponseData"); } JsonNode _resultsNode = _node.get("results"); if (_resultsNode == null) { throw new RuntimeException("CreateAclsResponseData: unable to locate field 'results', which is mandatory in version " + _version); } else { if (!_resultsNode.isArray()) { throw new RuntimeException("CreateAclsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<AclCreationResult> _collection = new ArrayList<AclCreationResult>(_resultsNode.size()); _object.results = _collection; for (JsonNode _element : _resultsNode) { _collection.add(AclCreationResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(CreateAclsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); ArrayNode _resultsArray = new ArrayNode(JsonNodeFactory.instance); for (AclCreationResult _element : _object.results) { _resultsArray.add(AclCreationResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("results", _resultsArray); return _node; } public static JsonNode write(CreateAclsResponseData _object, short _version) { return write(_object, _version, true); } public static class AclCreationResultJsonConverter { public static AclCreationResult read(JsonNode _node, short _version) { AclCreationResult _object = new AclCreationResult(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("AclCreationResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "AclCreationResult"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("AclCreationResult: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("AclCreationResult expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } return _object; } public static JsonNode write(AclCreationResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } return _node; } public static JsonNode write(AclCreationResult _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateDelegationTokenRequestData.java
/* * 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 CreateDelegationTokenRequestData implements ApiMessage { String ownerPrincipalType; String ownerPrincipalName; List<CreatableRenewers> renewers; long maxLifetimeMs; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("renewers", new ArrayOf(CreatableRenewers.SCHEMA_0), "A list of those who are allowed to renew this token before it expires."), new Field("max_lifetime_ms", Type.INT64, "The maximum lifetime of the token in milliseconds, or -1 to use the server side default.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("renewers", new CompactArrayOf(CreatableRenewers.SCHEMA_2), "A list of those who are allowed to renew this token before it expires."), new Field("max_lifetime_ms", Type.INT64, "The maximum lifetime of the token in milliseconds, or -1 to use the server side default."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = new Schema( new Field("owner_principal_type", Type.COMPACT_NULLABLE_STRING, "The principal type of the owner of the token. If it's null it defaults to the token request principal."), new Field("owner_principal_name", Type.COMPACT_NULLABLE_STRING, "The principal name of the owner of the token. If it's null it defaults to the token request principal."), new Field("renewers", new CompactArrayOf(CreatableRenewers.SCHEMA_2), "A list of those who are allowed to renew this token before it expires."), new Field("max_lifetime_ms", Type.INT64, "The maximum lifetime of the token in milliseconds, or -1 to use the server side default."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreateDelegationTokenRequestData(Readable _readable, short _version) { read(_readable, _version); } public CreateDelegationTokenRequestData() { this.ownerPrincipalType = ""; this.ownerPrincipalName = ""; this.renewers = new ArrayList<CreatableRenewers>(0); this.maxLifetimeMs = 0L; } @Override public short apiKey() { return 38; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version >= 3) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.ownerPrincipalType = null; } else if (length > 0x7fff) { throw new RuntimeException("string field ownerPrincipalType had invalid length " + length); } else { this.ownerPrincipalType = _readable.readString(length); } } else { this.ownerPrincipalType = ""; } if (_version >= 3) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.ownerPrincipalName = null; } else if (length > 0x7fff) { throw new RuntimeException("string field ownerPrincipalName had invalid length " + length); } else { this.ownerPrincipalName = _readable.readString(length); } } else { this.ownerPrincipalName = ""; } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field renewers 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<CreatableRenewers> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableRenewers(_readable, _version)); } this.renewers = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field renewers 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<CreatableRenewers> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableRenewers(_readable, _version)); } this.renewers = newCollection; } } } this.maxLifetimeMs = _readable.readLong(); 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; if (_version >= 3) { if (ownerPrincipalType == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(ownerPrincipalType); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } else { if (this.ownerPrincipalType == null || !this.ownerPrincipalType.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default ownerPrincipalType at version " + _version); } } if (_version >= 3) { if (ownerPrincipalName == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(ownerPrincipalName); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } else { if (this.ownerPrincipalName == null || !this.ownerPrincipalName.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default ownerPrincipalName at version " + _version); } } if (_version >= 2) { _writable.writeUnsignedVarint(renewers.size() + 1); for (CreatableRenewers renewersElement : renewers) { renewersElement.write(_writable, _cache, _version); } } else { _writable.writeInt(renewers.size()); for (CreatableRenewers renewersElement : renewers) { renewersElement.write(_writable, _cache, _version); } } _writable.writeLong(maxLifetimeMs); 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 >= 3) { if (ownerPrincipalType == null) { _size.addBytes(1); } else { byte[] _stringBytes = ownerPrincipalType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'ownerPrincipalType' field is too long to be serialized"); } _cache.cacheSerializedValue(ownerPrincipalType, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } } if (_version >= 3) { if (ownerPrincipalName == null) { _size.addBytes(1); } else { byte[] _stringBytes = ownerPrincipalName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'ownerPrincipalName' field is too long to be serialized"); } _cache.cacheSerializedValue(ownerPrincipalName, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(renewers.size() + 1)); } else { _size.addBytes(4); } for (CreatableRenewers renewersElement : renewers) { renewersElement.addSize(_size, _cache, _version); } } _size.addBytes(8); 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 CreateDelegationTokenRequestData)) return false; CreateDelegationTokenRequestData other = (CreateDelegationTokenRequestData) obj; if (this.ownerPrincipalType == null) { if (other.ownerPrincipalType != null) return false; } else { if (!this.ownerPrincipalType.equals(other.ownerPrincipalType)) return false; } if (this.ownerPrincipalName == null) { if (other.ownerPrincipalName != null) return false; } else { if (!this.ownerPrincipalName.equals(other.ownerPrincipalName)) return false; } if (this.renewers == null) { if (other.renewers != null) return false; } else { if (!this.renewers.equals(other.renewers)) return false; } if (maxLifetimeMs != other.maxLifetimeMs) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (ownerPrincipalType == null ? 0 : ownerPrincipalType.hashCode()); hashCode = 31 * hashCode + (ownerPrincipalName == null ? 0 : ownerPrincipalName.hashCode()); hashCode = 31 * hashCode + (renewers == null ? 0 : renewers.hashCode()); hashCode = 31 * hashCode + ((int) (maxLifetimeMs >> 32) ^ (int) maxLifetimeMs); return hashCode; } @Override public CreateDelegationTokenRequestData duplicate() { CreateDelegationTokenRequestData _duplicate = new CreateDelegationTokenRequestData(); if (ownerPrincipalType == null) { _duplicate.ownerPrincipalType = null; } else { _duplicate.ownerPrincipalType = ownerPrincipalType; } if (ownerPrincipalName == null) { _duplicate.ownerPrincipalName = null; } else { _duplicate.ownerPrincipalName = ownerPrincipalName; } ArrayList<CreatableRenewers> newRenewers = new ArrayList<CreatableRenewers>(renewers.size()); for (CreatableRenewers _element : renewers) { newRenewers.add(_element.duplicate()); } _duplicate.renewers = newRenewers; _duplicate.maxLifetimeMs = maxLifetimeMs; return _duplicate; } @Override public String toString() { return "CreateDelegationTokenRequestData(" + "ownerPrincipalType=" + ((ownerPrincipalType == null) ? "null" : "'" + ownerPrincipalType.toString() + "'") + ", ownerPrincipalName=" + ((ownerPrincipalName == null) ? "null" : "'" + ownerPrincipalName.toString() + "'") + ", renewers=" + MessageUtil.deepToString(renewers.iterator()) + ", maxLifetimeMs=" + maxLifetimeMs + ")"; } public String ownerPrincipalType() { return this.ownerPrincipalType; } public String ownerPrincipalName() { return this.ownerPrincipalName; } public List<CreatableRenewers> renewers() { return this.renewers; } public long maxLifetimeMs() { return this.maxLifetimeMs; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreateDelegationTokenRequestData setOwnerPrincipalType(String v) { this.ownerPrincipalType = v; return this; } public CreateDelegationTokenRequestData setOwnerPrincipalName(String v) { this.ownerPrincipalName = v; return this; } public CreateDelegationTokenRequestData setRenewers(List<CreatableRenewers> v) { this.renewers = v; return this; } public CreateDelegationTokenRequestData setMaxLifetimeMs(long v) { this.maxLifetimeMs = v; return this; } public static class CreatableRenewers implements Message { String principalType; String principalName; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("principal_type", Type.STRING, "The type of the Kafka principal."), new Field("principal_name", Type.STRING, "The name of the Kafka principal.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("principal_type", Type.COMPACT_STRING, "The type of the Kafka principal."), new Field("principal_name", Type.COMPACT_STRING, "The name of the Kafka principal."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreatableRenewers(Readable _readable, short _version) { read(_readable, _version); } public CreatableRenewers() { this.principalType = ""; this.principalName = ""; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatableRenewers"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalType had invalid length " + length); } else { this.principalType = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalName had invalid length " + length); } else { this.principalName = _readable.readString(length); } } 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(principalType); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(principalName); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreatableRenewers"); } { byte[] _stringBytes = principalType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalType' field is too long to be serialized"); } _cache.cacheSerializedValue(principalType, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = principalName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalName' field is too long to be serialized"); } _cache.cacheSerializedValue(principalName, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 CreatableRenewers)) return false; CreatableRenewers other = (CreatableRenewers) obj; if (this.principalType == null) { if (other.principalType != null) return false; } else { if (!this.principalType.equals(other.principalType)) return false; } if (this.principalName == null) { if (other.principalName != null) return false; } else { if (!this.principalName.equals(other.principalName)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (principalType == null ? 0 : principalType.hashCode()); hashCode = 31 * hashCode + (principalName == null ? 0 : principalName.hashCode()); return hashCode; } @Override public CreatableRenewers duplicate() { CreatableRenewers _duplicate = new CreatableRenewers(); _duplicate.principalType = principalType; _duplicate.principalName = principalName; return _duplicate; } @Override public String toString() { return "CreatableRenewers(" + "principalType=" + ((principalType == null) ? "null" : "'" + principalType.toString() + "'") + ", principalName=" + ((principalName == null) ? "null" : "'" + principalName.toString() + "'") + ")"; } public String principalType() { return this.principalType; } public String principalName() { return this.principalName; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatableRenewers setPrincipalType(String v) { this.principalType = v; return this; } public CreatableRenewers setPrincipalName(String v) { this.principalName = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateDelegationTokenRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.CreateDelegationTokenRequestData.*; public class CreateDelegationTokenRequestDataJsonConverter { public static CreateDelegationTokenRequestData read(JsonNode _node, short _version) { CreateDelegationTokenRequestData _object = new CreateDelegationTokenRequestData(); JsonNode _ownerPrincipalTypeNode = _node.get("ownerPrincipalType"); if (_ownerPrincipalTypeNode == null) { if (_version >= 3) { throw new RuntimeException("CreateDelegationTokenRequestData: unable to locate field 'ownerPrincipalType', which is mandatory in version " + _version); } else { _object.ownerPrincipalType = ""; } } else { if (_ownerPrincipalTypeNode.isNull()) { _object.ownerPrincipalType = null; } else { if (!_ownerPrincipalTypeNode.isTextual()) { throw new RuntimeException("CreateDelegationTokenRequestData expected a string type, but got " + _node.getNodeType()); } _object.ownerPrincipalType = _ownerPrincipalTypeNode.asText(); } } JsonNode _ownerPrincipalNameNode = _node.get("ownerPrincipalName"); if (_ownerPrincipalNameNode == null) { if (_version >= 3) { throw new RuntimeException("CreateDelegationTokenRequestData: unable to locate field 'ownerPrincipalName', which is mandatory in version " + _version); } else { _object.ownerPrincipalName = ""; } } else { if (_ownerPrincipalNameNode.isNull()) { _object.ownerPrincipalName = null; } else { if (!_ownerPrincipalNameNode.isTextual()) { throw new RuntimeException("CreateDelegationTokenRequestData expected a string type, but got " + _node.getNodeType()); } _object.ownerPrincipalName = _ownerPrincipalNameNode.asText(); } } JsonNode _renewersNode = _node.get("renewers"); if (_renewersNode == null) { throw new RuntimeException("CreateDelegationTokenRequestData: unable to locate field 'renewers', which is mandatory in version " + _version); } else { if (!_renewersNode.isArray()) { throw new RuntimeException("CreateDelegationTokenRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<CreatableRenewers> _collection = new ArrayList<CreatableRenewers>(_renewersNode.size()); _object.renewers = _collection; for (JsonNode _element : _renewersNode) { _collection.add(CreatableRenewersJsonConverter.read(_element, _version)); } } JsonNode _maxLifetimeMsNode = _node.get("maxLifetimeMs"); if (_maxLifetimeMsNode == null) { throw new RuntimeException("CreateDelegationTokenRequestData: unable to locate field 'maxLifetimeMs', which is mandatory in version " + _version); } else { _object.maxLifetimeMs = MessageUtil.jsonNodeToLong(_maxLifetimeMsNode, "CreateDelegationTokenRequestData"); } return _object; } public static JsonNode write(CreateDelegationTokenRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_version >= 3) { if (_object.ownerPrincipalType == null) { _node.set("ownerPrincipalType", NullNode.instance); } else { _node.set("ownerPrincipalType", new TextNode(_object.ownerPrincipalType)); } } else { if (_object.ownerPrincipalType == null || !_object.ownerPrincipalType.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default ownerPrincipalType at version " + _version); } } if (_version >= 3) { if (_object.ownerPrincipalName == null) { _node.set("ownerPrincipalName", NullNode.instance); } else { _node.set("ownerPrincipalName", new TextNode(_object.ownerPrincipalName)); } } else { if (_object.ownerPrincipalName == null || !_object.ownerPrincipalName.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default ownerPrincipalName at version " + _version); } } ArrayNode _renewersArray = new ArrayNode(JsonNodeFactory.instance); for (CreatableRenewers _element : _object.renewers) { _renewersArray.add(CreatableRenewersJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("renewers", _renewersArray); _node.set("maxLifetimeMs", new LongNode(_object.maxLifetimeMs)); return _node; } public static JsonNode write(CreateDelegationTokenRequestData _object, short _version) { return write(_object, _version, true); } public static class CreatableRenewersJsonConverter { public static CreatableRenewers read(JsonNode _node, short _version) { CreatableRenewers _object = new CreatableRenewers(); JsonNode _principalTypeNode = _node.get("principalType"); if (_principalTypeNode == null) { throw new RuntimeException("CreatableRenewers: unable to locate field 'principalType', which is mandatory in version " + _version); } else { if (!_principalTypeNode.isTextual()) { throw new RuntimeException("CreatableRenewers expected a string type, but got " + _node.getNodeType()); } _object.principalType = _principalTypeNode.asText(); } JsonNode _principalNameNode = _node.get("principalName"); if (_principalNameNode == null) { throw new RuntimeException("CreatableRenewers: unable to locate field 'principalName', which is mandatory in version " + _version); } else { if (!_principalNameNode.isTextual()) { throw new RuntimeException("CreatableRenewers expected a string type, but got " + _node.getNodeType()); } _object.principalName = _principalNameNode.asText(); } return _object; } public static JsonNode write(CreatableRenewers _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("principalType", new TextNode(_object.principalType)); _node.set("principalName", new TextNode(_object.principalName)); return _node; } public static JsonNode write(CreatableRenewers _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateDelegationTokenResponseData.java
/* * 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.Arrays; import java.util.List; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.ApiMessage; 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.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 org.apache.kafka.common.utils.Bytes; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class CreateDelegationTokenResponseData implements ApiMessage { short errorCode; String principalType; String principalName; String tokenRequesterPrincipalType; String tokenRequesterPrincipalName; long issueTimestampMs; long expiryTimestampMs; long maxTimestampMs; String tokenId; byte[] hmac; int throttleTimeMs; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The top-level error, or zero if there was no error."), new Field("principal_type", Type.STRING, "The principal type of the token owner."), new Field("principal_name", Type.STRING, "The name of the token owner."), new Field("issue_timestamp_ms", Type.INT64, "When this token was generated."), new Field("expiry_timestamp_ms", Type.INT64, "When this token expires."), new Field("max_timestamp_ms", Type.INT64, "The maximum lifetime of this token."), new Field("token_id", Type.STRING, "The token UUID."), new Field("hmac", Type.BYTES, "HMAC of the delegation token."), 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.") ); 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, or zero if there was no error."), new Field("principal_type", Type.COMPACT_STRING, "The principal type of the token owner."), new Field("principal_name", Type.COMPACT_STRING, "The name of the token owner."), new Field("issue_timestamp_ms", Type.INT64, "When this token was generated."), new Field("expiry_timestamp_ms", Type.INT64, "When this token expires."), new Field("max_timestamp_ms", Type.INT64, "The maximum lifetime of this token."), new Field("token_id", Type.COMPACT_STRING, "The token UUID."), new Field("hmac", Type.COMPACT_BYTES, "HMAC of the delegation token."), 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."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = new Schema( new Field("error_code", Type.INT16, "The top-level error, or zero if there was no error."), new Field("principal_type", Type.COMPACT_STRING, "The principal type of the token owner."), new Field("principal_name", Type.COMPACT_STRING, "The name of the token owner."), new Field("token_requester_principal_type", Type.COMPACT_STRING, "The principal type of the requester of the token."), new Field("token_requester_principal_name", Type.COMPACT_STRING, "The principal type of the requester of the token."), new Field("issue_timestamp_ms", Type.INT64, "When this token was generated."), new Field("expiry_timestamp_ms", Type.INT64, "When this token expires."), new Field("max_timestamp_ms", Type.INT64, "The maximum lifetime of this token."), new Field("token_id", Type.COMPACT_STRING, "The token UUID."), new Field("hmac", Type.COMPACT_BYTES, "HMAC of the delegation token."), 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."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreateDelegationTokenResponseData(Readable _readable, short _version) { read(_readable, _version); } public CreateDelegationTokenResponseData() { this.errorCode = (short) 0; this.principalType = ""; this.principalName = ""; this.tokenRequesterPrincipalType = ""; this.tokenRequesterPrincipalName = ""; this.issueTimestampMs = 0L; this.expiryTimestampMs = 0L; this.maxTimestampMs = 0L; this.tokenId = ""; this.hmac = Bytes.EMPTY; this.throttleTimeMs = 0; } @Override public short apiKey() { return 38; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { this.errorCode = _readable.readShort(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalType had invalid length " + length); } else { this.principalType = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalName had invalid length " + length); } else { this.principalName = _readable.readString(length); } } if (_version >= 3) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field tokenRequesterPrincipalType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field tokenRequesterPrincipalType had invalid length " + length); } else { this.tokenRequesterPrincipalType = _readable.readString(length); } } else { this.tokenRequesterPrincipalType = ""; } if (_version >= 3) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field tokenRequesterPrincipalName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field tokenRequesterPrincipalName had invalid length " + length); } else { this.tokenRequesterPrincipalName = _readable.readString(length); } } else { this.tokenRequesterPrincipalName = ""; } this.issueTimestampMs = _readable.readLong(); this.expiryTimestampMs = _readable.readLong(); this.maxTimestampMs = _readable.readLong(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field tokenId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field tokenId had invalid length " + length); } else { this.tokenId = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readInt(); } if (length < 0) { throw new RuntimeException("non-nullable field hmac was serialized as null"); } else { byte[] newBytes = _readable.readArray(length); this.hmac = newBytes; } } this.throttleTimeMs = _readable.readInt(); 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); { byte[] _stringBytes = _cache.getSerializedValue(principalType); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(principalName); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 3) { { byte[] _stringBytes = _cache.getSerializedValue(tokenRequesterPrincipalType); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } else { if (!this.tokenRequesterPrincipalType.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default tokenRequesterPrincipalType at version " + _version); } } if (_version >= 3) { { byte[] _stringBytes = _cache.getSerializedValue(tokenRequesterPrincipalName); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } else { if (!this.tokenRequesterPrincipalName.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default tokenRequesterPrincipalName at version " + _version); } } _writable.writeLong(issueTimestampMs); _writable.writeLong(expiryTimestampMs); _writable.writeLong(maxTimestampMs); { byte[] _stringBytes = _cache.getSerializedValue(tokenId); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(hmac.length + 1); } else { _writable.writeInt(hmac.length); } _writable.writeByteArray(hmac); _writable.writeInt(throttleTimeMs); 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); { byte[] _stringBytes = principalType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalType' field is too long to be serialized"); } _cache.cacheSerializedValue(principalType, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = principalName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalName' field is too long to be serialized"); } _cache.cacheSerializedValue(principalName, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 3) { { byte[] _stringBytes = tokenRequesterPrincipalType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'tokenRequesterPrincipalType' field is too long to be serialized"); } _cache.cacheSerializedValue(tokenRequesterPrincipalType, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } } if (_version >= 3) { { byte[] _stringBytes = tokenRequesterPrincipalName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'tokenRequesterPrincipalName' field is too long to be serialized"); } _cache.cacheSerializedValue(tokenRequesterPrincipalName, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } } _size.addBytes(8); _size.addBytes(8); _size.addBytes(8); { byte[] _stringBytes = tokenId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'tokenId' field is too long to be serialized"); } _cache.cacheSerializedValue(tokenId, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { _size.addBytes(hmac.length); if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(hmac.length + 1)); } else { _size.addBytes(4); } } _size.addBytes(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()); } } 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 CreateDelegationTokenResponseData)) return false; CreateDelegationTokenResponseData other = (CreateDelegationTokenResponseData) obj; if (errorCode != other.errorCode) return false; if (this.principalType == null) { if (other.principalType != null) return false; } else { if (!this.principalType.equals(other.principalType)) return false; } if (this.principalName == null) { if (other.principalName != null) return false; } else { if (!this.principalName.equals(other.principalName)) return false; } if (this.tokenRequesterPrincipalType == null) { if (other.tokenRequesterPrincipalType != null) return false; } else { if (!this.tokenRequesterPrincipalType.equals(other.tokenRequesterPrincipalType)) return false; } if (this.tokenRequesterPrincipalName == null) { if (other.tokenRequesterPrincipalName != null) return false; } else { if (!this.tokenRequesterPrincipalName.equals(other.tokenRequesterPrincipalName)) return false; } if (issueTimestampMs != other.issueTimestampMs) return false; if (expiryTimestampMs != other.expiryTimestampMs) return false; if (maxTimestampMs != other.maxTimestampMs) return false; if (this.tokenId == null) { if (other.tokenId != null) return false; } else { if (!this.tokenId.equals(other.tokenId)) return false; } if (!Arrays.equals(this.hmac, other.hmac)) return false; if (throttleTimeMs != other.throttleTimeMs) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (principalType == null ? 0 : principalType.hashCode()); hashCode = 31 * hashCode + (principalName == null ? 0 : principalName.hashCode()); hashCode = 31 * hashCode + (tokenRequesterPrincipalType == null ? 0 : tokenRequesterPrincipalType.hashCode()); hashCode = 31 * hashCode + (tokenRequesterPrincipalName == null ? 0 : tokenRequesterPrincipalName.hashCode()); hashCode = 31 * hashCode + ((int) (issueTimestampMs >> 32) ^ (int) issueTimestampMs); hashCode = 31 * hashCode + ((int) (expiryTimestampMs >> 32) ^ (int) expiryTimestampMs); hashCode = 31 * hashCode + ((int) (maxTimestampMs >> 32) ^ (int) maxTimestampMs); hashCode = 31 * hashCode + (tokenId == null ? 0 : tokenId.hashCode()); hashCode = 31 * hashCode + Arrays.hashCode(hmac); hashCode = 31 * hashCode + throttleTimeMs; return hashCode; } @Override public CreateDelegationTokenResponseData duplicate() { CreateDelegationTokenResponseData _duplicate = new CreateDelegationTokenResponseData(); _duplicate.errorCode = errorCode; _duplicate.principalType = principalType; _duplicate.principalName = principalName; _duplicate.tokenRequesterPrincipalType = tokenRequesterPrincipalType; _duplicate.tokenRequesterPrincipalName = tokenRequesterPrincipalName; _duplicate.issueTimestampMs = issueTimestampMs; _duplicate.expiryTimestampMs = expiryTimestampMs; _duplicate.maxTimestampMs = maxTimestampMs; _duplicate.tokenId = tokenId; _duplicate.hmac = MessageUtil.duplicate(hmac); _duplicate.throttleTimeMs = throttleTimeMs; return _duplicate; } @Override public String toString() { return "CreateDelegationTokenResponseData(" + "errorCode=" + errorCode + ", principalType=" + ((principalType == null) ? "null" : "'" + principalType.toString() + "'") + ", principalName=" + ((principalName == null) ? "null" : "'" + principalName.toString() + "'") + ", tokenRequesterPrincipalType=" + ((tokenRequesterPrincipalType == null) ? "null" : "'" + tokenRequesterPrincipalType.toString() + "'") + ", tokenRequesterPrincipalName=" + ((tokenRequesterPrincipalName == null) ? "null" : "'" + tokenRequesterPrincipalName.toString() + "'") + ", issueTimestampMs=" + issueTimestampMs + ", expiryTimestampMs=" + expiryTimestampMs + ", maxTimestampMs=" + maxTimestampMs + ", tokenId=" + ((tokenId == null) ? "null" : "'" + tokenId.toString() + "'") + ", hmac=" + Arrays.toString(hmac) + ", throttleTimeMs=" + throttleTimeMs + ")"; } public short errorCode() { return this.errorCode; } public String principalType() { return this.principalType; } public String principalName() { return this.principalName; } public String tokenRequesterPrincipalType() { return this.tokenRequesterPrincipalType; } public String tokenRequesterPrincipalName() { return this.tokenRequesterPrincipalName; } public long issueTimestampMs() { return this.issueTimestampMs; } public long expiryTimestampMs() { return this.expiryTimestampMs; } public long maxTimestampMs() { return this.maxTimestampMs; } public String tokenId() { return this.tokenId; } public byte[] hmac() { return this.hmac; } public int throttleTimeMs() { return this.throttleTimeMs; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreateDelegationTokenResponseData setErrorCode(short v) { this.errorCode = v; return this; } public CreateDelegationTokenResponseData setPrincipalType(String v) { this.principalType = v; return this; } public CreateDelegationTokenResponseData setPrincipalName(String v) { this.principalName = v; return this; } public CreateDelegationTokenResponseData setTokenRequesterPrincipalType(String v) { this.tokenRequesterPrincipalType = v; return this; } public CreateDelegationTokenResponseData setTokenRequesterPrincipalName(String v) { this.tokenRequesterPrincipalName = v; return this; } public CreateDelegationTokenResponseData setIssueTimestampMs(long v) { this.issueTimestampMs = v; return this; } public CreateDelegationTokenResponseData setExpiryTimestampMs(long v) { this.expiryTimestampMs = v; return this; } public CreateDelegationTokenResponseData setMaxTimestampMs(long v) { this.maxTimestampMs = v; return this; } public CreateDelegationTokenResponseData setTokenId(String v) { this.tokenId = v; return this; } public CreateDelegationTokenResponseData setHmac(byte[] v) { this.hmac = v; return this; } public CreateDelegationTokenResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateDelegationTokenResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.BinaryNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.Arrays; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.CreateDelegationTokenResponseData.*; public class CreateDelegationTokenResponseDataJsonConverter { public static CreateDelegationTokenResponseData read(JsonNode _node, short _version) { CreateDelegationTokenResponseData _object = new CreateDelegationTokenResponseData(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "CreateDelegationTokenResponseData"); } JsonNode _principalTypeNode = _node.get("principalType"); if (_principalTypeNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'principalType', which is mandatory in version " + _version); } else { if (!_principalTypeNode.isTextual()) { throw new RuntimeException("CreateDelegationTokenResponseData expected a string type, but got " + _node.getNodeType()); } _object.principalType = _principalTypeNode.asText(); } JsonNode _principalNameNode = _node.get("principalName"); if (_principalNameNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'principalName', which is mandatory in version " + _version); } else { if (!_principalNameNode.isTextual()) { throw new RuntimeException("CreateDelegationTokenResponseData expected a string type, but got " + _node.getNodeType()); } _object.principalName = _principalNameNode.asText(); } JsonNode _tokenRequesterPrincipalTypeNode = _node.get("tokenRequesterPrincipalType"); if (_tokenRequesterPrincipalTypeNode == null) { if (_version >= 3) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'tokenRequesterPrincipalType', which is mandatory in version " + _version); } else { _object.tokenRequesterPrincipalType = ""; } } else { if (!_tokenRequesterPrincipalTypeNode.isTextual()) { throw new RuntimeException("CreateDelegationTokenResponseData expected a string type, but got " + _node.getNodeType()); } _object.tokenRequesterPrincipalType = _tokenRequesterPrincipalTypeNode.asText(); } JsonNode _tokenRequesterPrincipalNameNode = _node.get("tokenRequesterPrincipalName"); if (_tokenRequesterPrincipalNameNode == null) { if (_version >= 3) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'tokenRequesterPrincipalName', which is mandatory in version " + _version); } else { _object.tokenRequesterPrincipalName = ""; } } else { if (!_tokenRequesterPrincipalNameNode.isTextual()) { throw new RuntimeException("CreateDelegationTokenResponseData expected a string type, but got " + _node.getNodeType()); } _object.tokenRequesterPrincipalName = _tokenRequesterPrincipalNameNode.asText(); } JsonNode _issueTimestampMsNode = _node.get("issueTimestampMs"); if (_issueTimestampMsNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'issueTimestampMs', which is mandatory in version " + _version); } else { _object.issueTimestampMs = MessageUtil.jsonNodeToLong(_issueTimestampMsNode, "CreateDelegationTokenResponseData"); } JsonNode _expiryTimestampMsNode = _node.get("expiryTimestampMs"); if (_expiryTimestampMsNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'expiryTimestampMs', which is mandatory in version " + _version); } else { _object.expiryTimestampMs = MessageUtil.jsonNodeToLong(_expiryTimestampMsNode, "CreateDelegationTokenResponseData"); } JsonNode _maxTimestampMsNode = _node.get("maxTimestampMs"); if (_maxTimestampMsNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'maxTimestampMs', which is mandatory in version " + _version); } else { _object.maxTimestampMs = MessageUtil.jsonNodeToLong(_maxTimestampMsNode, "CreateDelegationTokenResponseData"); } JsonNode _tokenIdNode = _node.get("tokenId"); if (_tokenIdNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'tokenId', which is mandatory in version " + _version); } else { if (!_tokenIdNode.isTextual()) { throw new RuntimeException("CreateDelegationTokenResponseData expected a string type, but got " + _node.getNodeType()); } _object.tokenId = _tokenIdNode.asText(); } JsonNode _hmacNode = _node.get("hmac"); if (_hmacNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'hmac', which is mandatory in version " + _version); } else { _object.hmac = MessageUtil.jsonNodeToBinary(_hmacNode, "CreateDelegationTokenResponseData"); } JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("CreateDelegationTokenResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "CreateDelegationTokenResponseData"); } return _object; } public static JsonNode write(CreateDelegationTokenResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); _node.set("principalType", new TextNode(_object.principalType)); _node.set("principalName", new TextNode(_object.principalName)); if (_version >= 3) { _node.set("tokenRequesterPrincipalType", new TextNode(_object.tokenRequesterPrincipalType)); } else { if (!_object.tokenRequesterPrincipalType.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default tokenRequesterPrincipalType at version " + _version); } } if (_version >= 3) { _node.set("tokenRequesterPrincipalName", new TextNode(_object.tokenRequesterPrincipalName)); } else { if (!_object.tokenRequesterPrincipalName.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default tokenRequesterPrincipalName at version " + _version); } } _node.set("issueTimestampMs", new LongNode(_object.issueTimestampMs)); _node.set("expiryTimestampMs", new LongNode(_object.expiryTimestampMs)); _node.set("maxTimestampMs", new LongNode(_object.maxTimestampMs)); _node.set("tokenId", new TextNode(_object.tokenId)); _node.set("hmac", new BinaryNode(Arrays.copyOf(_object.hmac, _object.hmac.length))); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); return _node; } public static JsonNode write(CreateDelegationTokenResponseData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreatePartitionsRequestData.java
/* * 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.Iterator; 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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class CreatePartitionsRequestData implements ApiMessage { CreatePartitionsTopicCollection topics; int timeoutMs; boolean validateOnly; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topics", new ArrayOf(CreatePartitionsTopic.SCHEMA_0), "Each topic that we want to create new partitions inside."), new Field("timeout_ms", Type.INT32, "The time in ms to wait for the partitions to be created."), new Field("validate_only", Type.BOOLEAN, "If true, then validate the request, but don't actually increase the number of partitions.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("topics", new CompactArrayOf(CreatePartitionsTopic.SCHEMA_2), "Each topic that we want to create new partitions inside."), new Field("timeout_ms", Type.INT32, "The time in ms to wait for the partitions to be created."), new Field("validate_only", Type.BOOLEAN, "If true, then validate the request, but don't actually increase the number of partitions."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreatePartitionsRequestData(Readable _readable, short _version) { read(_readable, _version); } public CreatePartitionsRequestData() { this.topics = new CreatePartitionsTopicCollection(0); this.timeoutMs = 0; this.validateOnly = false; } @Override public short apiKey() { return 37; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } CreatePartitionsTopicCollection newCollection = new CreatePartitionsTopicCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatePartitionsTopic(_readable, _version)); } this.topics = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } CreatePartitionsTopicCollection newCollection = new CreatePartitionsTopicCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatePartitionsTopic(_readable, _version)); } this.topics = newCollection; } } } this.timeoutMs = _readable.readInt(); this.validateOnly = _readable.readByte() != 0; 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; if (_version >= 2) { _writable.writeUnsignedVarint(topics.size() + 1); for (CreatePartitionsTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(topics.size()); for (CreatePartitionsTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } _writable.writeInt(timeoutMs); _writable.writeByte(validateOnly ? (byte) 1 : (byte) 0); 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 >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); } else { _size.addBytes(4); } for (CreatePartitionsTopic topicsElement : topics) { topicsElement.addSize(_size, _cache, _version); } } _size.addBytes(4); _size.addBytes(1); 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 CreatePartitionsRequestData)) return false; CreatePartitionsRequestData other = (CreatePartitionsRequestData) obj; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } if (timeoutMs != other.timeoutMs) return false; if (validateOnly != other.validateOnly) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); hashCode = 31 * hashCode + timeoutMs; hashCode = 31 * hashCode + (validateOnly ? 1231 : 1237); return hashCode; } @Override public CreatePartitionsRequestData duplicate() { CreatePartitionsRequestData _duplicate = new CreatePartitionsRequestData(); CreatePartitionsTopicCollection newTopics = new CreatePartitionsTopicCollection(topics.size()); for (CreatePartitionsTopic _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; _duplicate.timeoutMs = timeoutMs; _duplicate.validateOnly = validateOnly; return _duplicate; } @Override public String toString() { return "CreatePartitionsRequestData(" + "topics=" + MessageUtil.deepToString(topics.iterator()) + ", timeoutMs=" + timeoutMs + ", validateOnly=" + (validateOnly ? "true" : "false") + ")"; } public CreatePartitionsTopicCollection topics() { return this.topics; } public int timeoutMs() { return this.timeoutMs; } public boolean validateOnly() { return this.validateOnly; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatePartitionsRequestData setTopics(CreatePartitionsTopicCollection v) { this.topics = v; return this; } public CreatePartitionsRequestData setTimeoutMs(int v) { this.timeoutMs = v; return this; } public CreatePartitionsRequestData setValidateOnly(boolean v) { this.validateOnly = v; return this; } public static class CreatePartitionsTopic implements Message, ImplicitLinkedHashMultiCollection.Element { String name; int count; List<CreatePartitionsAssignment> assignments; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The topic name."), new Field("count", Type.INT32, "The new partition count."), new Field("assignments", ArrayOf.nullable(CreatePartitionsAssignment.SCHEMA_0), "The new partition assignments.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("count", Type.INT32, "The new partition count."), new Field("assignments", CompactArrayOf.nullable(CreatePartitionsAssignment.SCHEMA_2), "The new partition assignments."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreatePartitionsTopic(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public CreatePartitionsTopic() { this.name = ""; this.count = 0; this.assignments = new ArrayList<CreatePartitionsAssignment>(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatePartitionsTopic"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } this.count = _readable.readInt(); { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.assignments = 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<CreatePartitionsAssignment> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatePartitionsAssignment(_readable, _version)); } this.assignments = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { this.assignments = 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<CreatePartitionsAssignment> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatePartitionsAssignment(_readable, _version)); } this.assignments = 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; { byte[] _stringBytes = _cache.getSerializedValue(name); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeInt(count); if (_version >= 2) { if (assignments == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(assignments.size() + 1); for (CreatePartitionsAssignment assignmentsElement : assignments) { assignmentsElement.write(_writable, _cache, _version); } } } else { if (assignments == null) { _writable.writeInt(-1); } else { _writable.writeInt(assignments.size()); for (CreatePartitionsAssignment assignmentsElement : assignments) { assignmentsElement.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; if (_version > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreatePartitionsTopic"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(4); if (assignments == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(4); } } else { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(assignments.size() + 1)); } else { _size.addBytes(4); } for (CreatePartitionsAssignment assignmentsElement : assignments) { assignmentsElement.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 elementKeysAreEqual(Object obj) { if (!(obj instanceof CreatePartitionsTopic)) return false; CreatePartitionsTopic other = (CreatePartitionsTopic) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof CreatePartitionsTopic)) return false; CreatePartitionsTopic other = (CreatePartitionsTopic) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (count != other.count) return false; if (this.assignments == null) { if (other.assignments != null) return false; } else { if (!this.assignments.equals(other.assignments)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); return hashCode; } @Override public CreatePartitionsTopic duplicate() { CreatePartitionsTopic _duplicate = new CreatePartitionsTopic(); _duplicate.name = name; _duplicate.count = count; if (assignments == null) { _duplicate.assignments = null; } else { ArrayList<CreatePartitionsAssignment> newAssignments = new ArrayList<CreatePartitionsAssignment>(assignments.size()); for (CreatePartitionsAssignment _element : assignments) { newAssignments.add(_element.duplicate()); } _duplicate.assignments = newAssignments; } return _duplicate; } @Override public String toString() { return "CreatePartitionsTopic(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", count=" + count + ", assignments=" + ((assignments == null) ? "null" : MessageUtil.deepToString(assignments.iterator())) + ")"; } public String name() { return this.name; } public int count() { return this.count; } public List<CreatePartitionsAssignment> assignments() { return this.assignments; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatePartitionsTopic setName(String v) { this.name = v; return this; } public CreatePartitionsTopic setCount(int v) { this.count = v; return this; } public CreatePartitionsTopic setAssignments(List<CreatePartitionsAssignment> v) { this.assignments = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class CreatePartitionsAssignment implements Message { List<Integer> brokerIds; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("broker_ids", new ArrayOf(Type.INT32), "The assigned broker IDs.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("broker_ids", new CompactArrayOf(Type.INT32), "The assigned broker IDs."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreatePartitionsAssignment(Readable _readable, short _version) { read(_readable, _version); } public CreatePartitionsAssignment() { this.brokerIds = new ArrayList<Integer>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatePartitionsAssignment"); } { int arrayLength; if (_version >= 2) { arrayLength = _readable.readUnsignedVarint() - 1; } else { arrayLength = _readable.readInt(); } if (arrayLength < 0) { throw new RuntimeException("non-nullable field brokerIds 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<Integer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(_readable.readInt()); } this.brokerIds = 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; if (_version >= 2) { _writable.writeUnsignedVarint(brokerIds.size() + 1); } else { _writable.writeInt(brokerIds.size()); } for (Integer brokerIdsElement : brokerIds) { _writable.writeInt(brokerIdsElement); } 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreatePartitionsAssignment"); } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(brokerIds.size() + 1)); } else { _size.addBytes(4); } _size.addBytes(brokerIds.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()); } } 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 CreatePartitionsAssignment)) return false; CreatePartitionsAssignment other = (CreatePartitionsAssignment) obj; if (this.brokerIds == null) { if (other.brokerIds != null) return false; } else { if (!this.brokerIds.equals(other.brokerIds)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (brokerIds == null ? 0 : brokerIds.hashCode()); return hashCode; } @Override public CreatePartitionsAssignment duplicate() { CreatePartitionsAssignment _duplicate = new CreatePartitionsAssignment(); ArrayList<Integer> newBrokerIds = new ArrayList<Integer>(brokerIds.size()); for (Integer _element : brokerIds) { newBrokerIds.add(_element); } _duplicate.brokerIds = newBrokerIds; return _duplicate; } @Override public String toString() { return "CreatePartitionsAssignment(" + "brokerIds=" + MessageUtil.deepToString(brokerIds.iterator()) + ")"; } public List<Integer> brokerIds() { return this.brokerIds; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatePartitionsAssignment setBrokerIds(List<Integer> v) { this.brokerIds = v; return this; } } public static class CreatePartitionsTopicCollection extends ImplicitLinkedHashMultiCollection<CreatePartitionsTopic> { public CreatePartitionsTopicCollection() { super(); } public CreatePartitionsTopicCollection(int expectedNumElements) { super(expectedNumElements); } public CreatePartitionsTopicCollection(Iterator<CreatePartitionsTopic> iterator) { super(iterator); } public CreatePartitionsTopic find(String name) { CreatePartitionsTopic _key = new CreatePartitionsTopic(); _key.setName(name); return find(_key); } public List<CreatePartitionsTopic> findAll(String name) { CreatePartitionsTopic _key = new CreatePartitionsTopic(); _key.setName(name); return findAll(_key); } public CreatePartitionsTopicCollection duplicate() { CreatePartitionsTopicCollection _duplicate = new CreatePartitionsTopicCollection(size()); for (CreatePartitionsTopic _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreatePartitionsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.CreatePartitionsRequestData.*; public class CreatePartitionsRequestDataJsonConverter { public static CreatePartitionsRequestData read(JsonNode _node, short _version) { CreatePartitionsRequestData _object = new CreatePartitionsRequestData(); JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("CreatePartitionsRequestData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("CreatePartitionsRequestData expected a JSON array, but got " + _node.getNodeType()); } CreatePartitionsTopicCollection _collection = new CreatePartitionsTopicCollection(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(CreatePartitionsTopicJsonConverter.read(_element, _version)); } } JsonNode _timeoutMsNode = _node.get("timeoutMs"); if (_timeoutMsNode == null) { throw new RuntimeException("CreatePartitionsRequestData: unable to locate field 'timeoutMs', which is mandatory in version " + _version); } else { _object.timeoutMs = MessageUtil.jsonNodeToInt(_timeoutMsNode, "CreatePartitionsRequestData"); } JsonNode _validateOnlyNode = _node.get("validateOnly"); if (_validateOnlyNode == null) { throw new RuntimeException("CreatePartitionsRequestData: unable to locate field 'validateOnly', which is mandatory in version " + _version); } else { if (!_validateOnlyNode.isBoolean()) { throw new RuntimeException("CreatePartitionsRequestData expected Boolean type, but got " + _node.getNodeType()); } _object.validateOnly = _validateOnlyNode.asBoolean(); } return _object; } public static JsonNode write(CreatePartitionsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (CreatePartitionsTopic _element : _object.topics) { _topicsArray.add(CreatePartitionsTopicJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); _node.set("timeoutMs", new IntNode(_object.timeoutMs)); _node.set("validateOnly", BooleanNode.valueOf(_object.validateOnly)); return _node; } public static JsonNode write(CreatePartitionsRequestData _object, short _version) { return write(_object, _version, true); } public static class CreatePartitionsAssignmentJsonConverter { public static CreatePartitionsAssignment read(JsonNode _node, short _version) { CreatePartitionsAssignment _object = new CreatePartitionsAssignment(); JsonNode _brokerIdsNode = _node.get("brokerIds"); if (_brokerIdsNode == null) { throw new RuntimeException("CreatePartitionsAssignment: unable to locate field 'brokerIds', which is mandatory in version " + _version); } else { if (!_brokerIdsNode.isArray()) { throw new RuntimeException("CreatePartitionsAssignment expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_brokerIdsNode.size()); _object.brokerIds = _collection; for (JsonNode _element : _brokerIdsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "CreatePartitionsAssignment element")); } } return _object; } public static JsonNode write(CreatePartitionsAssignment _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _brokerIdsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.brokerIds) { _brokerIdsArray.add(new IntNode(_element)); } _node.set("brokerIds", _brokerIdsArray); return _node; } public static JsonNode write(CreatePartitionsAssignment _object, short _version) { return write(_object, _version, true); } } public static class CreatePartitionsTopicJsonConverter { public static CreatePartitionsTopic read(JsonNode _node, short _version) { CreatePartitionsTopic _object = new CreatePartitionsTopic(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("CreatePartitionsTopic: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("CreatePartitionsTopic expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _countNode = _node.get("count"); if (_countNode == null) { throw new RuntimeException("CreatePartitionsTopic: unable to locate field 'count', which is mandatory in version " + _version); } else { _object.count = MessageUtil.jsonNodeToInt(_countNode, "CreatePartitionsTopic"); } JsonNode _assignmentsNode = _node.get("assignments"); if (_assignmentsNode == null) { throw new RuntimeException("CreatePartitionsTopic: unable to locate field 'assignments', which is mandatory in version " + _version); } else { if (_assignmentsNode.isNull()) { _object.assignments = null; } else { if (!_assignmentsNode.isArray()) { throw new RuntimeException("CreatePartitionsTopic expected a JSON array, but got " + _node.getNodeType()); } ArrayList<CreatePartitionsAssignment> _collection = new ArrayList<CreatePartitionsAssignment>(_assignmentsNode.size()); _object.assignments = _collection; for (JsonNode _element : _assignmentsNode) { _collection.add(CreatePartitionsAssignmentJsonConverter.read(_element, _version)); } } } return _object; } public static JsonNode write(CreatePartitionsTopic _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); _node.set("count", new IntNode(_object.count)); if (_object.assignments == null) { _node.set("assignments", NullNode.instance); } else { ArrayNode _assignmentsArray = new ArrayNode(JsonNodeFactory.instance); for (CreatePartitionsAssignment _element : _object.assignments) { _assignmentsArray.add(CreatePartitionsAssignmentJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("assignments", _assignmentsArray); } return _node; } public static JsonNode write(CreatePartitionsTopic _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreatePartitionsResponseData.java
/* * 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 CreatePartitionsResponseData implements ApiMessage { int throttleTimeMs; List<CreatePartitionsTopicResult> results; private List<RawTaggedField> _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("results", new ArrayOf(CreatePartitionsTopicResult.SCHEMA_0), "The partition creation results for each topic.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = 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("results", new CompactArrayOf(CreatePartitionsTopicResult.SCHEMA_2), "The partition creation results for each topic."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreatePartitionsResponseData(Readable _readable, short _version) { read(_readable, _version); } public CreatePartitionsResponseData() { this.throttleTimeMs = 0; this.results = new ArrayList<CreatePartitionsTopicResult>(0); } @Override public short apiKey() { return 37; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<CreatePartitionsTopicResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatePartitionsTopicResult(_readable, _version)); } this.results = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<CreatePartitionsTopicResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatePartitionsTopicResult(_readable, _version)); } this.results = 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.writeInt(throttleTimeMs); if (_version >= 2) { _writable.writeUnsignedVarint(results.size() + 1); for (CreatePartitionsTopicResult resultsElement : results) { resultsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(results.size()); for (CreatePartitionsTopicResult resultsElement : results) { resultsElement.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(4); { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(results.size() + 1)); } else { _size.addBytes(4); } for (CreatePartitionsTopicResult resultsElement : results) { resultsElement.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 CreatePartitionsResponseData)) return false; CreatePartitionsResponseData other = (CreatePartitionsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.results == null) { if (other.results != null) return false; } else { if (!this.results.equals(other.results)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (results == null ? 0 : results.hashCode()); return hashCode; } @Override public CreatePartitionsResponseData duplicate() { CreatePartitionsResponseData _duplicate = new CreatePartitionsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; ArrayList<CreatePartitionsTopicResult> newResults = new ArrayList<CreatePartitionsTopicResult>(results.size()); for (CreatePartitionsTopicResult _element : results) { newResults.add(_element.duplicate()); } _duplicate.results = newResults; return _duplicate; } @Override public String toString() { return "CreatePartitionsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", results=" + MessageUtil.deepToString(results.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public List<CreatePartitionsTopicResult> results() { return this.results; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatePartitionsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public CreatePartitionsResponseData setResults(List<CreatePartitionsTopicResult> v) { this.results = v; return this; } public static class CreatePartitionsTopicResult implements Message { String name; short errorCode; String errorMessage; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The topic name."), new Field("error_code", Type.INT16, "The result error, or zero if there was no error."), new Field("error_message", Type.NULLABLE_STRING, "The result message, or null if there was no error.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("error_code", Type.INT16, "The result error, or zero if there was no error."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The result message, or null if there was no error."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public CreatePartitionsTopicResult(Readable _readable, short _version) { read(_readable, _version); } public CreatePartitionsTopicResult() { this.name = ""; this.errorCode = (short) 0; this.errorMessage = null; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatePartitionsTopicResult"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } this.errorCode = _readable.readShort(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } 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(name); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeShort(errorCode); if (errorMessage == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreatePartitionsTopicResult"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(2); if (errorMessage == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 CreatePartitionsTopicResult)) return false; CreatePartitionsTopicResult other = (CreatePartitionsTopicResult) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) 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; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode()); return hashCode; } @Override public CreatePartitionsTopicResult duplicate() { CreatePartitionsTopicResult _duplicate = new CreatePartitionsTopicResult(); _duplicate.name = name; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } return _duplicate; } @Override public String toString() { return "CreatePartitionsTopicResult(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ")"; } public String name() { return this.name; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatePartitionsTopicResult setName(String v) { this.name = v; return this; } public CreatePartitionsTopicResult setErrorCode(short v) { this.errorCode = v; return this; } public CreatePartitionsTopicResult setErrorMessage(String v) { this.errorMessage = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreatePartitionsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.CreatePartitionsResponseData.*; public class CreatePartitionsResponseDataJsonConverter { public static CreatePartitionsResponseData read(JsonNode _node, short _version) { CreatePartitionsResponseData _object = new CreatePartitionsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("CreatePartitionsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "CreatePartitionsResponseData"); } JsonNode _resultsNode = _node.get("results"); if (_resultsNode == null) { throw new RuntimeException("CreatePartitionsResponseData: unable to locate field 'results', which is mandatory in version " + _version); } else { if (!_resultsNode.isArray()) { throw new RuntimeException("CreatePartitionsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<CreatePartitionsTopicResult> _collection = new ArrayList<CreatePartitionsTopicResult>(_resultsNode.size()); _object.results = _collection; for (JsonNode _element : _resultsNode) { _collection.add(CreatePartitionsTopicResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(CreatePartitionsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); ArrayNode _resultsArray = new ArrayNode(JsonNodeFactory.instance); for (CreatePartitionsTopicResult _element : _object.results) { _resultsArray.add(CreatePartitionsTopicResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("results", _resultsArray); return _node; } public static JsonNode write(CreatePartitionsResponseData _object, short _version) { return write(_object, _version, true); } public static class CreatePartitionsTopicResultJsonConverter { public static CreatePartitionsTopicResult read(JsonNode _node, short _version) { CreatePartitionsTopicResult _object = new CreatePartitionsTopicResult(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("CreatePartitionsTopicResult: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("CreatePartitionsTopicResult expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("CreatePartitionsTopicResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "CreatePartitionsTopicResult"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("CreatePartitionsTopicResult: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("CreatePartitionsTopicResult expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } return _object; } public static JsonNode write(CreatePartitionsTopicResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } return _node; } public static JsonNode write(CreatePartitionsTopicResult _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateTopicsRequestData.java
/* * 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.Iterator; 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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class CreateTopicsRequestData implements ApiMessage { CreatableTopicCollection topics; int timeoutMs; boolean validateOnly; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topics", new ArrayOf(CreatableTopic.SCHEMA_0), "The topics to create."), new Field("timeout_ms", Type.INT32, "How long to wait in milliseconds before timing out the request.") ); public static final Schema SCHEMA_1 = new Schema( new Field("topics", new ArrayOf(CreatableTopic.SCHEMA_0), "The topics to create."), new Field("timeout_ms", Type.INT32, "How long to wait in milliseconds before timing out the request."), new Field("validate_only", Type.BOOLEAN, "If true, check that the topics can be created as specified, but don't create anything.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = SCHEMA_3; public static final Schema SCHEMA_5 = new Schema( new Field("topics", new CompactArrayOf(CreatableTopic.SCHEMA_5), "The topics to create."), new Field("timeout_ms", Type.INT32, "How long to wait in milliseconds before timing out the request."), new Field("validate_only", Type.BOOLEAN, "If true, check that the topics can be created as specified, but don't create anything."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_6 = SCHEMA_5; public static final Schema SCHEMA_7 = SCHEMA_6; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6, SCHEMA_7 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 7; public CreateTopicsRequestData(Readable _readable, short _version) { read(_readable, _version); } public CreateTopicsRequestData() { this.topics = new CreatableTopicCollection(0); this.timeoutMs = 60000; this.validateOnly = false; } @Override public short apiKey() { return 19; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 7; } @Override public void read(Readable _readable, short _version) { { if (_version >= 5) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } CreatableTopicCollection newCollection = new CreatableTopicCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableTopic(_readable, _version)); } this.topics = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } CreatableTopicCollection newCollection = new CreatableTopicCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableTopic(_readable, _version)); } this.topics = newCollection; } } } this.timeoutMs = _readable.readInt(); if (_version >= 1) { this.validateOnly = _readable.readByte() != 0; } else { this.validateOnly = false; } this._unknownTaggedFields = null; if (_version >= 5) { 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; if (_version >= 5) { _writable.writeUnsignedVarint(topics.size() + 1); for (CreatableTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(topics.size()); for (CreatableTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } _writable.writeInt(timeoutMs); if (_version >= 1) { _writable.writeByte(validateOnly ? (byte) 1 : (byte) 0); } else { if (this.validateOnly) { throw new UnsupportedVersionException("Attempted to write a non-default validateOnly at version " + _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); } else { _size.addBytes(4); } for (CreatableTopic topicsElement : topics) { topicsElement.addSize(_size, _cache, _version); } } _size.addBytes(4); if (_version >= 1) { _size.addBytes(1); } 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 >= 5) { _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 CreateTopicsRequestData)) return false; CreateTopicsRequestData other = (CreateTopicsRequestData) obj; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } if (timeoutMs != other.timeoutMs) return false; if (validateOnly != other.validateOnly) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); hashCode = 31 * hashCode + timeoutMs; hashCode = 31 * hashCode + (validateOnly ? 1231 : 1237); return hashCode; } @Override public CreateTopicsRequestData duplicate() { CreateTopicsRequestData _duplicate = new CreateTopicsRequestData(); CreatableTopicCollection newTopics = new CreatableTopicCollection(topics.size()); for (CreatableTopic _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; _duplicate.timeoutMs = timeoutMs; _duplicate.validateOnly = validateOnly; return _duplicate; } @Override public String toString() { return "CreateTopicsRequestData(" + "topics=" + MessageUtil.deepToString(topics.iterator()) + ", timeoutMs=" + timeoutMs + ", validateOnly=" + (validateOnly ? "true" : "false") + ")"; } public CreatableTopicCollection topics() { return this.topics; } public int timeoutMs() { return this.timeoutMs; } public boolean validateOnly() { return this.validateOnly; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreateTopicsRequestData setTopics(CreatableTopicCollection v) { this.topics = v; return this; } public CreateTopicsRequestData setTimeoutMs(int v) { this.timeoutMs = v; return this; } public CreateTopicsRequestData setValidateOnly(boolean v) { this.validateOnly = v; return this; } public static class CreatableTopic implements Message, ImplicitLinkedHashMultiCollection.Element { String name; int numPartitions; short replicationFactor; CreatableReplicaAssignmentCollection assignments; CreateableTopicConfigCollection configs; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The topic name."), new Field("num_partitions", Type.INT32, "The number of partitions to create in the topic, or -1 if we are either specifying a manual partition assignment or using the default partitions."), new Field("replication_factor", Type.INT16, "The number of replicas to create for each partition in the topic, or -1 if we are either specifying a manual partition assignment or using the default replication factor."), new Field("assignments", new ArrayOf(CreatableReplicaAssignment.SCHEMA_0), "The manual partition assignment, or the empty array if we are using automatic assignment."), new Field("configs", new ArrayOf(CreateableTopicConfig.SCHEMA_0), "The custom topic configurations to set.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = SCHEMA_3; public static final Schema SCHEMA_5 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("num_partitions", Type.INT32, "The number of partitions to create in the topic, or -1 if we are either specifying a manual partition assignment or using the default partitions."), new Field("replication_factor", Type.INT16, "The number of replicas to create for each partition in the topic, or -1 if we are either specifying a manual partition assignment or using the default replication factor."), new Field("assignments", new CompactArrayOf(CreatableReplicaAssignment.SCHEMA_5), "The manual partition assignment, or the empty array if we are using automatic assignment."), new Field("configs", new CompactArrayOf(CreateableTopicConfig.SCHEMA_5), "The custom topic configurations to set."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_6 = SCHEMA_5; public static final Schema SCHEMA_7 = SCHEMA_6; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6, SCHEMA_7 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 7; public CreatableTopic(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public CreatableTopic() { this.name = ""; this.numPartitions = 0; this.replicationFactor = (short) 0; this.assignments = new CreatableReplicaAssignmentCollection(0); this.configs = new CreateableTopicConfigCollection(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 7; } @Override public void read(Readable _readable, short _version) { if (_version > 7) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatableTopic"); } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } this.numPartitions = _readable.readInt(); this.replicationFactor = _readable.readShort(); { if (_version >= 5) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field assignments 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."); } CreatableReplicaAssignmentCollection newCollection = new CreatableReplicaAssignmentCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableReplicaAssignment(_readable, _version)); } this.assignments = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field assignments 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."); } CreatableReplicaAssignmentCollection newCollection = new CreatableReplicaAssignmentCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableReplicaAssignment(_readable, _version)); } this.assignments = newCollection; } } } { if (_version >= 5) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field configs 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."); } CreateableTopicConfigCollection newCollection = new CreateableTopicConfigCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreateableTopicConfig(_readable, _version)); } this.configs = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field configs 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."); } CreateableTopicConfigCollection newCollection = new CreateableTopicConfigCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreateableTopicConfig(_readable, _version)); } this.configs = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 5) { 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(name); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeInt(numPartitions); _writable.writeShort(replicationFactor); if (_version >= 5) { _writable.writeUnsignedVarint(assignments.size() + 1); for (CreatableReplicaAssignment assignmentsElement : assignments) { assignmentsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(assignments.size()); for (CreatableReplicaAssignment assignmentsElement : assignments) { assignmentsElement.write(_writable, _cache, _version); } } if (_version >= 5) { _writable.writeUnsignedVarint(configs.size() + 1); for (CreateableTopicConfig configsElement : configs) { configsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(configs.size()); for (CreateableTopicConfig configsElement : configs) { configsElement.write(_writable, _cache, _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 > 7) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreatableTopic"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(4); _size.addBytes(2); { if (_version >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(assignments.size() + 1)); } else { _size.addBytes(4); } for (CreatableReplicaAssignment assignmentsElement : assignments) { assignmentsElement.addSize(_size, _cache, _version); } } { if (_version >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(configs.size() + 1)); } else { _size.addBytes(4); } for (CreateableTopicConfig configsElement : configs) { configsElement.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 >= 5) { _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof CreatableTopic)) return false; CreatableTopic other = (CreatableTopic) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof CreatableTopic)) return false; CreatableTopic other = (CreatableTopic) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (numPartitions != other.numPartitions) return false; if (replicationFactor != other.replicationFactor) return false; if (this.assignments == null) { if (other.assignments != null) return false; } else { if (!this.assignments.equals(other.assignments)) return false; } if (this.configs == null) { if (other.configs != null) return false; } else { if (!this.configs.equals(other.configs)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); return hashCode; } @Override public CreatableTopic duplicate() { CreatableTopic _duplicate = new CreatableTopic(); _duplicate.name = name; _duplicate.numPartitions = numPartitions; _duplicate.replicationFactor = replicationFactor; CreatableReplicaAssignmentCollection newAssignments = new CreatableReplicaAssignmentCollection(assignments.size()); for (CreatableReplicaAssignment _element : assignments) { newAssignments.add(_element.duplicate()); } _duplicate.assignments = newAssignments; CreateableTopicConfigCollection newConfigs = new CreateableTopicConfigCollection(configs.size()); for (CreateableTopicConfig _element : configs) { newConfigs.add(_element.duplicate()); } _duplicate.configs = newConfigs; return _duplicate; } @Override public String toString() { return "CreatableTopic(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", numPartitions=" + numPartitions + ", replicationFactor=" + replicationFactor + ", assignments=" + MessageUtil.deepToString(assignments.iterator()) + ", configs=" + MessageUtil.deepToString(configs.iterator()) + ")"; } public String name() { return this.name; } public int numPartitions() { return this.numPartitions; } public short replicationFactor() { return this.replicationFactor; } public CreatableReplicaAssignmentCollection assignments() { return this.assignments; } public CreateableTopicConfigCollection configs() { return this.configs; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatableTopic setName(String v) { this.name = v; return this; } public CreatableTopic setNumPartitions(int v) { this.numPartitions = v; return this; } public CreatableTopic setReplicationFactor(short v) { this.replicationFactor = v; return this; } public CreatableTopic setAssignments(CreatableReplicaAssignmentCollection v) { this.assignments = v; return this; } public CreatableTopic setConfigs(CreateableTopicConfigCollection v) { this.configs = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class CreatableReplicaAssignment implements Message, ImplicitLinkedHashMultiCollection.Element { int partitionIndex; List<Integer> brokerIds; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("broker_ids", new ArrayOf(Type.INT32), "The brokers to place the partition on.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = SCHEMA_3; public static final Schema SCHEMA_5 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("broker_ids", new CompactArrayOf(Type.INT32), "The brokers to place the partition on."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_6 = SCHEMA_5; public static final Schema SCHEMA_7 = SCHEMA_6; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6, SCHEMA_7 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 7; public CreatableReplicaAssignment(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public CreatableReplicaAssignment() { this.partitionIndex = 0; this.brokerIds = new ArrayList<Integer>(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 7; } @Override public void read(Readable _readable, short _version) { if (_version > 7) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatableReplicaAssignment"); } this.partitionIndex = _readable.readInt(); { int arrayLength; if (_version >= 5) { arrayLength = _readable.readUnsignedVarint() - 1; } else { arrayLength = _readable.readInt(); } if (arrayLength < 0) { throw new RuntimeException("non-nullable field brokerIds 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<Integer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(_readable.readInt()); } this.brokerIds = newCollection; } } this._unknownTaggedFields = null; if (_version >= 5) { 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(partitionIndex); if (_version >= 5) { _writable.writeUnsignedVarint(brokerIds.size() + 1); } else { _writable.writeInt(brokerIds.size()); } for (Integer brokerIdsElement : brokerIds) { _writable.writeInt(brokerIdsElement); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 > 7) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreatableReplicaAssignment"); } _size.addBytes(4); { if (_version >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(brokerIds.size() + 1)); } else { _size.addBytes(4); } _size.addBytes(brokerIds.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()); } } if (_version >= 5) { _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof CreatableReplicaAssignment)) return false; CreatableReplicaAssignment other = (CreatableReplicaAssignment) obj; if (partitionIndex != other.partitionIndex) return false; return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof CreatableReplicaAssignment)) return false; CreatableReplicaAssignment other = (CreatableReplicaAssignment) obj; if (partitionIndex != other.partitionIndex) return false; if (this.brokerIds == null) { if (other.brokerIds != null) return false; } else { if (!this.brokerIds.equals(other.brokerIds)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; return hashCode; } @Override public CreatableReplicaAssignment duplicate() { CreatableReplicaAssignment _duplicate = new CreatableReplicaAssignment(); _duplicate.partitionIndex = partitionIndex; ArrayList<Integer> newBrokerIds = new ArrayList<Integer>(brokerIds.size()); for (Integer _element : brokerIds) { newBrokerIds.add(_element); } _duplicate.brokerIds = newBrokerIds; return _duplicate; } @Override public String toString() { return "CreatableReplicaAssignment(" + "partitionIndex=" + partitionIndex + ", brokerIds=" + MessageUtil.deepToString(brokerIds.iterator()) + ")"; } public int partitionIndex() { return this.partitionIndex; } public List<Integer> brokerIds() { return this.brokerIds; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatableReplicaAssignment setPartitionIndex(int v) { this.partitionIndex = v; return this; } public CreatableReplicaAssignment setBrokerIds(List<Integer> v) { this.brokerIds = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class CreatableReplicaAssignmentCollection extends ImplicitLinkedHashMultiCollection<CreatableReplicaAssignment> { public CreatableReplicaAssignmentCollection() { super(); } public CreatableReplicaAssignmentCollection(int expectedNumElements) { super(expectedNumElements); } public CreatableReplicaAssignmentCollection(Iterator<CreatableReplicaAssignment> iterator) { super(iterator); } public CreatableReplicaAssignment find(int partitionIndex) { CreatableReplicaAssignment _key = new CreatableReplicaAssignment(); _key.setPartitionIndex(partitionIndex); return find(_key); } public List<CreatableReplicaAssignment> findAll(int partitionIndex) { CreatableReplicaAssignment _key = new CreatableReplicaAssignment(); _key.setPartitionIndex(partitionIndex); return findAll(_key); } public CreatableReplicaAssignmentCollection duplicate() { CreatableReplicaAssignmentCollection _duplicate = new CreatableReplicaAssignmentCollection(size()); for (CreatableReplicaAssignment _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } public static class CreateableTopicConfig implements Message, ImplicitLinkedHashMultiCollection.Element { String name; String value; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The configuration name."), new Field("value", Type.NULLABLE_STRING, "The configuration value.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = SCHEMA_3; public static final Schema SCHEMA_5 = new Schema( new Field("name", Type.COMPACT_STRING, "The configuration name."), new Field("value", Type.COMPACT_NULLABLE_STRING, "The configuration value."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_6 = SCHEMA_5; public static final Schema SCHEMA_7 = SCHEMA_6; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6, SCHEMA_7 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 7; public CreateableTopicConfig(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public CreateableTopicConfig() { this.name = ""; this.value = ""; this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 7; } @Override public void read(Readable _readable, short _version) { if (_version > 7) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreateableTopicConfig"); } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.value = null; } else if (length > 0x7fff) { throw new RuntimeException("string field value had invalid length " + length); } else { this.value = _readable.readString(length); } } this._unknownTaggedFields = null; if (_version >= 5) { 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(name); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (value == null) { if (_version >= 5) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(value); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 > 7) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreateableTopicConfig"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (value == null) { if (_version >= 5) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = value.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'value' field is too long to be serialized"); } _cache.cacheSerializedValue(value, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 >= 5) { _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof CreateableTopicConfig)) return false; CreateableTopicConfig other = (CreateableTopicConfig) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof CreateableTopicConfig)) return false; CreateableTopicConfig other = (CreateableTopicConfig) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (this.value == null) { if (other.value != null) return false; } else { if (!this.value.equals(other.value)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); return hashCode; } @Override public CreateableTopicConfig duplicate() { CreateableTopicConfig _duplicate = new CreateableTopicConfig(); _duplicate.name = name; if (value == null) { _duplicate.value = null; } else { _duplicate.value = value; } return _duplicate; } @Override public String toString() { return "CreateableTopicConfig(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", value=" + ((value == null) ? "null" : "'" + value.toString() + "'") + ")"; } public String name() { return this.name; } public String value() { return this.value; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreateableTopicConfig setName(String v) { this.name = v; return this; } public CreateableTopicConfig setValue(String v) { this.value = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class CreateableTopicConfigCollection extends ImplicitLinkedHashMultiCollection<CreateableTopicConfig> { public CreateableTopicConfigCollection() { super(); } public CreateableTopicConfigCollection(int expectedNumElements) { super(expectedNumElements); } public CreateableTopicConfigCollection(Iterator<CreateableTopicConfig> iterator) { super(iterator); } public CreateableTopicConfig find(String name) { CreateableTopicConfig _key = new CreateableTopicConfig(); _key.setName(name); return find(_key); } public List<CreateableTopicConfig> findAll(String name) { CreateableTopicConfig _key = new CreateableTopicConfig(); _key.setName(name); return findAll(_key); } public CreateableTopicConfigCollection duplicate() { CreateableTopicConfigCollection _duplicate = new CreateableTopicConfigCollection(size()); for (CreateableTopicConfig _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } public static class CreatableTopicCollection extends ImplicitLinkedHashMultiCollection<CreatableTopic> { public CreatableTopicCollection() { super(); } public CreatableTopicCollection(int expectedNumElements) { super(expectedNumElements); } public CreatableTopicCollection(Iterator<CreatableTopic> iterator) { super(iterator); } public CreatableTopic find(String name) { CreatableTopic _key = new CreatableTopic(); _key.setName(name); return find(_key); } public List<CreatableTopic> findAll(String name) { CreatableTopic _key = new CreatableTopic(); _key.setName(name); return findAll(_key); } public CreatableTopicCollection duplicate() { CreatableTopicCollection _duplicate = new CreatableTopicCollection(size()); for (CreatableTopic _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateTopicsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.CreateTopicsRequestData.*; public class CreateTopicsRequestDataJsonConverter { public static CreateTopicsRequestData read(JsonNode _node, short _version) { CreateTopicsRequestData _object = new CreateTopicsRequestData(); JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("CreateTopicsRequestData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("CreateTopicsRequestData expected a JSON array, but got " + _node.getNodeType()); } CreatableTopicCollection _collection = new CreatableTopicCollection(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(CreatableTopicJsonConverter.read(_element, _version)); } } JsonNode _timeoutMsNode = _node.get("timeoutMs"); if (_timeoutMsNode == null) { throw new RuntimeException("CreateTopicsRequestData: unable to locate field 'timeoutMs', which is mandatory in version " + _version); } else { _object.timeoutMs = MessageUtil.jsonNodeToInt(_timeoutMsNode, "CreateTopicsRequestData"); } JsonNode _validateOnlyNode = _node.get("validateOnly"); if (_validateOnlyNode == null) { if (_version >= 1) { throw new RuntimeException("CreateTopicsRequestData: unable to locate field 'validateOnly', which is mandatory in version " + _version); } else { _object.validateOnly = false; } } else { if (!_validateOnlyNode.isBoolean()) { throw new RuntimeException("CreateTopicsRequestData expected Boolean type, but got " + _node.getNodeType()); } _object.validateOnly = _validateOnlyNode.asBoolean(); } return _object; } public static JsonNode write(CreateTopicsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (CreatableTopic _element : _object.topics) { _topicsArray.add(CreatableTopicJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); _node.set("timeoutMs", new IntNode(_object.timeoutMs)); if (_version >= 1) { _node.set("validateOnly", BooleanNode.valueOf(_object.validateOnly)); } else { if (_object.validateOnly) { throw new UnsupportedVersionException("Attempted to write a non-default validateOnly at version " + _version); } } return _node; } public static JsonNode write(CreateTopicsRequestData _object, short _version) { return write(_object, _version, true); } public static class CreatableReplicaAssignmentJsonConverter { public static CreatableReplicaAssignment read(JsonNode _node, short _version) { CreatableReplicaAssignment _object = new CreatableReplicaAssignment(); JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("CreatableReplicaAssignment: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "CreatableReplicaAssignment"); } JsonNode _brokerIdsNode = _node.get("brokerIds"); if (_brokerIdsNode == null) { throw new RuntimeException("CreatableReplicaAssignment: unable to locate field 'brokerIds', which is mandatory in version " + _version); } else { if (!_brokerIdsNode.isArray()) { throw new RuntimeException("CreatableReplicaAssignment expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_brokerIdsNode.size()); _object.brokerIds = _collection; for (JsonNode _element : _brokerIdsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "CreatableReplicaAssignment element")); } } return _object; } public static JsonNode write(CreatableReplicaAssignment _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); ArrayNode _brokerIdsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.brokerIds) { _brokerIdsArray.add(new IntNode(_element)); } _node.set("brokerIds", _brokerIdsArray); return _node; } public static JsonNode write(CreatableReplicaAssignment _object, short _version) { return write(_object, _version, true); } } public static class CreatableTopicJsonConverter { public static CreatableTopic read(JsonNode _node, short _version) { CreatableTopic _object = new CreatableTopic(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("CreatableTopic: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("CreatableTopic expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _numPartitionsNode = _node.get("numPartitions"); if (_numPartitionsNode == null) { throw new RuntimeException("CreatableTopic: unable to locate field 'numPartitions', which is mandatory in version " + _version); } else { _object.numPartitions = MessageUtil.jsonNodeToInt(_numPartitionsNode, "CreatableTopic"); } JsonNode _replicationFactorNode = _node.get("replicationFactor"); if (_replicationFactorNode == null) { throw new RuntimeException("CreatableTopic: unable to locate field 'replicationFactor', which is mandatory in version " + _version); } else { _object.replicationFactor = MessageUtil.jsonNodeToShort(_replicationFactorNode, "CreatableTopic"); } JsonNode _assignmentsNode = _node.get("assignments"); if (_assignmentsNode == null) { throw new RuntimeException("CreatableTopic: unable to locate field 'assignments', which is mandatory in version " + _version); } else { if (!_assignmentsNode.isArray()) { throw new RuntimeException("CreatableTopic expected a JSON array, but got " + _node.getNodeType()); } CreatableReplicaAssignmentCollection _collection = new CreatableReplicaAssignmentCollection(_assignmentsNode.size()); _object.assignments = _collection; for (JsonNode _element : _assignmentsNode) { _collection.add(CreatableReplicaAssignmentJsonConverter.read(_element, _version)); } } JsonNode _configsNode = _node.get("configs"); if (_configsNode == null) { throw new RuntimeException("CreatableTopic: unable to locate field 'configs', which is mandatory in version " + _version); } else { if (!_configsNode.isArray()) { throw new RuntimeException("CreatableTopic expected a JSON array, but got " + _node.getNodeType()); } CreateableTopicConfigCollection _collection = new CreateableTopicConfigCollection(_configsNode.size()); _object.configs = _collection; for (JsonNode _element : _configsNode) { _collection.add(CreateableTopicConfigJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(CreatableTopic _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); _node.set("numPartitions", new IntNode(_object.numPartitions)); _node.set("replicationFactor", new ShortNode(_object.replicationFactor)); ArrayNode _assignmentsArray = new ArrayNode(JsonNodeFactory.instance); for (CreatableReplicaAssignment _element : _object.assignments) { _assignmentsArray.add(CreatableReplicaAssignmentJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("assignments", _assignmentsArray); ArrayNode _configsArray = new ArrayNode(JsonNodeFactory.instance); for (CreateableTopicConfig _element : _object.configs) { _configsArray.add(CreateableTopicConfigJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("configs", _configsArray); return _node; } public static JsonNode write(CreatableTopic _object, short _version) { return write(_object, _version, true); } } public static class CreateableTopicConfigJsonConverter { public static CreateableTopicConfig read(JsonNode _node, short _version) { CreateableTopicConfig _object = new CreateableTopicConfig(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("CreateableTopicConfig: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("CreateableTopicConfig expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _valueNode = _node.get("value"); if (_valueNode == null) { throw new RuntimeException("CreateableTopicConfig: unable to locate field 'value', which is mandatory in version " + _version); } else { if (_valueNode.isNull()) { _object.value = null; } else { if (!_valueNode.isTextual()) { throw new RuntimeException("CreateableTopicConfig expected a string type, but got " + _node.getNodeType()); } _object.value = _valueNode.asText(); } } return _object; } public static JsonNode write(CreateableTopicConfig _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); if (_object.value == null) { _node.set("value", NullNode.instance); } else { _node.set("value", new TextNode(_object.value)); } return _node; } public static JsonNode write(CreateableTopicConfig _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateTopicsResponseData.java
/* * 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.Iterator; 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.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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class CreateTopicsResponseData implements ApiMessage { int throttleTimeMs; CreatableTopicResultCollection topics; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topics", new ArrayOf(CreatableTopicResult.SCHEMA_0), "Results for each topic we tried to create.") ); public static final Schema SCHEMA_1 = new Schema( new Field("topics", new ArrayOf(CreatableTopicResult.SCHEMA_1), "Results for each topic we tried to create.") ); public static final Schema SCHEMA_2 = 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("topics", new ArrayOf(CreatableTopicResult.SCHEMA_1), "Results for each topic we tried to create.") ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = SCHEMA_3; public static final Schema SCHEMA_5 = 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("topics", new CompactArrayOf(CreatableTopicResult.SCHEMA_5), "Results for each topic we tried to create."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_6 = SCHEMA_5; public static final Schema SCHEMA_7 = 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("topics", new CompactArrayOf(CreatableTopicResult.SCHEMA_7), "Results for each topic we tried to create."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6, SCHEMA_7 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 7; public CreateTopicsResponseData(Readable _readable, short _version) { read(_readable, _version); } public CreateTopicsResponseData() { this.throttleTimeMs = 0; this.topics = new CreatableTopicResultCollection(0); } @Override public short apiKey() { return 19; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 7; } @Override public void read(Readable _readable, short _version) { if (_version >= 2) { this.throttleTimeMs = _readable.readInt(); } else { this.throttleTimeMs = 0; } { if (_version >= 5) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } CreatableTopicResultCollection newCollection = new CreatableTopicResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableTopicResult(_readable, _version)); } this.topics = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } CreatableTopicResultCollection newCollection = new CreatableTopicResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableTopicResult(_readable, _version)); } this.topics = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 5) { 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; if (_version >= 2) { _writable.writeInt(throttleTimeMs); } if (_version >= 5) { _writable.writeUnsignedVarint(topics.size() + 1); for (CreatableTopicResult topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(topics.size()); for (CreatableTopicResult topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 >= 2) { _size.addBytes(4); } { if (_version >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); } else { _size.addBytes(4); } for (CreatableTopicResult topicsElement : topics) { topicsElement.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 >= 5) { _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 CreateTopicsResponseData)) return false; CreateTopicsResponseData other = (CreateTopicsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public CreateTopicsResponseData duplicate() { CreateTopicsResponseData _duplicate = new CreateTopicsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; CreatableTopicResultCollection newTopics = new CreatableTopicResultCollection(topics.size()); for (CreatableTopicResult _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "CreateTopicsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public CreatableTopicResultCollection topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreateTopicsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public CreateTopicsResponseData setTopics(CreatableTopicResultCollection v) { this.topics = v; return this; } public static class CreatableTopicResult implements Message, ImplicitLinkedHashMultiCollection.Element { String name; Uuid topicId; short errorCode; String errorMessage; short topicConfigErrorCode; int numPartitions; short replicationFactor; List<CreatableTopicConfigs> configs; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The topic name."), new Field("error_code", Type.INT16, "The error code, or 0 if there was no error.") ); public static final Schema SCHEMA_1 = new Schema( new Field("name", Type.STRING, "The topic name."), new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or null if there was no error.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = SCHEMA_3; public static final Schema SCHEMA_5 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The error message, or null if there was no error."), new Field("num_partitions", Type.INT32, "Number of partitions of the topic."), new Field("replication_factor", Type.INT16, "Replication factor of the topic."), new Field("configs", CompactArrayOf.nullable(CreatableTopicConfigs.SCHEMA_5), "Configuration of the topic."), TaggedFieldsSection.of( 0, new Field("topic_config_error_code", Type.INT16, "Optional topic config error returned if configs are not returned in the response.") ) ); public static final Schema SCHEMA_6 = SCHEMA_5; public static final Schema SCHEMA_7 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("topic_id", Type.UUID, "The unique topic ID"), new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The error message, or null if there was no error."), new Field("num_partitions", Type.INT32, "Number of partitions of the topic."), new Field("replication_factor", Type.INT16, "Replication factor of the topic."), new Field("configs", CompactArrayOf.nullable(CreatableTopicConfigs.SCHEMA_5), "Configuration of the topic."), TaggedFieldsSection.of( 0, new Field("topic_config_error_code", Type.INT16, "Optional topic config error returned if configs are not returned in the response.") ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6, SCHEMA_7 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 7; public CreatableTopicResult(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public CreatableTopicResult() { this.name = ""; this.topicId = Uuid.ZERO_UUID; this.errorCode = (short) 0; this.errorMessage = ""; this.topicConfigErrorCode = (short) 0; this.numPartitions = -1; this.replicationFactor = (short) -1; this.configs = new ArrayList<CreatableTopicConfigs>(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 7; } @Override public void read(Readable _readable, short _version) { if (_version > 7) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatableTopicResult"); } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } if (_version >= 7) { this.topicId = _readable.readUuid(); } else { this.topicId = Uuid.ZERO_UUID; } this.errorCode = _readable.readShort(); if (_version >= 1) { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } else { this.errorMessage = ""; } this.topicConfigErrorCode = (short) 0; if (_version >= 5) { this.numPartitions = _readable.readInt(); } else { this.numPartitions = -1; } if (_version >= 5) { this.replicationFactor = _readable.readShort(); } else { this.replicationFactor = (short) -1; } if (_version >= 5) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.configs = 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<CreatableTopicConfigs> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CreatableTopicConfigs(_readable, _version)); } this.configs = newCollection; } } else { this.configs = new ArrayList<CreatableTopicConfigs>(0); } this._unknownTaggedFields = null; if (_version >= 5) { int _numTaggedFields = _readable.readUnsignedVarint(); for (int _i = 0; _i < _numTaggedFields; _i++) { int _tag = _readable.readUnsignedVarint(); int _size = _readable.readUnsignedVarint(); switch (_tag) { case 0: { this.topicConfigErrorCode = _readable.readShort(); break; } 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(name); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 7) { _writable.writeUuid(topicId); } _writable.writeShort(errorCode); if (_version >= 1) { if (errorMessage == null) { if (_version >= 5) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } } if (_version >= 5) { if (this.topicConfigErrorCode != (short) 0) { _numTaggedFields++; } } if (_version >= 5) { _writable.writeInt(numPartitions); } if (_version >= 5) { _writable.writeShort(replicationFactor); } if (_version >= 5) { if (configs == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(configs.size() + 1); for (CreatableTopicConfigs configsElement : configs) { configsElement.write(_writable, _cache, _version); } } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _writable.writeUnsignedVarint(_numTaggedFields); { if (this.topicConfigErrorCode != (short) 0) { _writable.writeUnsignedVarint(0); _writable.writeUnsignedVarint(2); _writable.writeShort(topicConfigErrorCode); } } _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 > 7) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreatableTopicResult"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 7) { _size.addBytes(16); } _size.addBytes(2); if (_version >= 1) { if (errorMessage == null) { if (_version >= 5) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } } if (_version >= 5) { if (this.topicConfigErrorCode != (short) 0) { _numTaggedFields++; _size.addBytes(1); _size.addBytes(1); _size.addBytes(2); } } if (_version >= 5) { _size.addBytes(4); } if (_version >= 5) { _size.addBytes(2); } if (_version >= 5) { if (configs == null) { _size.addBytes(1); } else { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(configs.size() + 1)); for (CreatableTopicConfigs configsElement : configs) { configsElement.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 >= 5) { _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof CreatableTopicResult)) return false; CreatableTopicResult other = (CreatableTopicResult) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof CreatableTopicResult)) return false; CreatableTopicResult other = (CreatableTopicResult) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (!this.topicId.equals(other.topicId)) 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 (topicConfigErrorCode != other.topicConfigErrorCode) return false; if (numPartitions != other.numPartitions) return false; if (replicationFactor != other.replicationFactor) return false; if (this.configs == null) { if (other.configs != null) return false; } else { if (!this.configs.equals(other.configs)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); return hashCode; } @Override public CreatableTopicResult duplicate() { CreatableTopicResult _duplicate = new CreatableTopicResult(); _duplicate.name = name; _duplicate.topicId = topicId; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } _duplicate.topicConfigErrorCode = topicConfigErrorCode; _duplicate.numPartitions = numPartitions; _duplicate.replicationFactor = replicationFactor; if (configs == null) { _duplicate.configs = null; } else { ArrayList<CreatableTopicConfigs> newConfigs = new ArrayList<CreatableTopicConfigs>(configs.size()); for (CreatableTopicConfigs _element : configs) { newConfigs.add(_element.duplicate()); } _duplicate.configs = newConfigs; } return _duplicate; } @Override public String toString() { return "CreatableTopicResult(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", topicId=" + topicId.toString() + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", topicConfigErrorCode=" + topicConfigErrorCode + ", numPartitions=" + numPartitions + ", replicationFactor=" + replicationFactor + ", configs=" + ((configs == null) ? "null" : MessageUtil.deepToString(configs.iterator())) + ")"; } public String name() { return this.name; } public Uuid topicId() { return this.topicId; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public short topicConfigErrorCode() { return this.topicConfigErrorCode; } public int numPartitions() { return this.numPartitions; } public short replicationFactor() { return this.replicationFactor; } public List<CreatableTopicConfigs> configs() { return this.configs; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatableTopicResult setName(String v) { this.name = v; return this; } public CreatableTopicResult setTopicId(Uuid v) { this.topicId = v; return this; } public CreatableTopicResult setErrorCode(short v) { this.errorCode = v; return this; } public CreatableTopicResult setErrorMessage(String v) { this.errorMessage = v; return this; } public CreatableTopicResult setTopicConfigErrorCode(short v) { this.topicConfigErrorCode = v; return this; } public CreatableTopicResult setNumPartitions(int v) { this.numPartitions = v; return this; } public CreatableTopicResult setReplicationFactor(short v) { this.replicationFactor = v; return this; } public CreatableTopicResult setConfigs(List<CreatableTopicConfigs> v) { this.configs = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class CreatableTopicConfigs implements Message { String name; String value; boolean readOnly; byte configSource; boolean isSensitive; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_5 = new Schema( new Field("name", Type.COMPACT_STRING, "The configuration name."), new Field("value", Type.COMPACT_NULLABLE_STRING, "The configuration value."), new Field("read_only", Type.BOOLEAN, "True if the configuration is read-only."), new Field("config_source", Type.INT8, "The configuration source."), new Field("is_sensitive", Type.BOOLEAN, "True if this configuration is sensitive."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_6 = SCHEMA_5; public static final Schema SCHEMA_7 = SCHEMA_6; public static final Schema[] SCHEMAS = new Schema[] { null, null, null, null, null, SCHEMA_5, SCHEMA_6, SCHEMA_7 }; public static final short LOWEST_SUPPORTED_VERSION = 5; public static final short HIGHEST_SUPPORTED_VERSION = 7; public CreatableTopicConfigs(Readable _readable, short _version) { read(_readable, _version); } public CreatableTopicConfigs() { this.name = ""; this.value = ""; this.readOnly = false; this.configSource = (byte) -1; this.isSensitive = false; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 7; } @Override public void read(Readable _readable, short _version) { if (_version > 7) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatableTopicConfigs"); } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.value = null; } else if (length > 0x7fff) { throw new RuntimeException("string field value had invalid length " + length); } else { this.value = _readable.readString(length); } } this.readOnly = _readable.readByte() != 0; this.configSource = _readable.readByte(); this.isSensitive = _readable.readByte() != 0; 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) { if (_version < 5) { throw new UnsupportedVersionException("Can't write version " + _version + " of CreatableTopicConfigs"); } int _numTaggedFields = 0; { byte[] _stringBytes = _cache.getSerializedValue(name); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } if (value == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(value); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeByte(readOnly ? (byte) 1 : (byte) 0); _writable.writeByte(configSource); _writable.writeByte(isSensitive ? (byte) 1 : (byte) 0); 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 > 7) { throw new UnsupportedVersionException("Can't size version " + _version + " of CreatableTopicConfigs"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } if (value == null) { _size.addBytes(1); } else { byte[] _stringBytes = value.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'value' field is too long to be serialized"); } _cache.cacheSerializedValue(value, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _size.addBytes(1); _size.addBytes(1); _size.addBytes(1); 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 CreatableTopicConfigs)) return false; CreatableTopicConfigs other = (CreatableTopicConfigs) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (this.value == null) { if (other.value != null) return false; } else { if (!this.value.equals(other.value)) return false; } if (readOnly != other.readOnly) return false; if (configSource != other.configSource) return false; if (isSensitive != other.isSensitive) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + (value == null ? 0 : value.hashCode()); hashCode = 31 * hashCode + (readOnly ? 1231 : 1237); hashCode = 31 * hashCode + configSource; hashCode = 31 * hashCode + (isSensitive ? 1231 : 1237); return hashCode; } @Override public CreatableTopicConfigs duplicate() { CreatableTopicConfigs _duplicate = new CreatableTopicConfigs(); _duplicate.name = name; if (value == null) { _duplicate.value = null; } else { _duplicate.value = value; } _duplicate.readOnly = readOnly; _duplicate.configSource = configSource; _duplicate.isSensitive = isSensitive; return _duplicate; } @Override public String toString() { return "CreatableTopicConfigs(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", value=" + ((value == null) ? "null" : "'" + value.toString() + "'") + ", readOnly=" + (readOnly ? "true" : "false") + ", configSource=" + configSource + ", isSensitive=" + (isSensitive ? "true" : "false") + ")"; } public String name() { return this.name; } public String value() { return this.value; } public boolean readOnly() { return this.readOnly; } public byte configSource() { return this.configSource; } public boolean isSensitive() { return this.isSensitive; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CreatableTopicConfigs setName(String v) { this.name = v; return this; } public CreatableTopicConfigs setValue(String v) { this.value = v; return this; } public CreatableTopicConfigs setReadOnly(boolean v) { this.readOnly = v; return this; } public CreatableTopicConfigs setConfigSource(byte v) { this.configSource = v; return this; } public CreatableTopicConfigs setIsSensitive(boolean v) { this.isSensitive = v; return this; } } public static class CreatableTopicResultCollection extends ImplicitLinkedHashMultiCollection<CreatableTopicResult> { public CreatableTopicResultCollection() { super(); } public CreatableTopicResultCollection(int expectedNumElements) { super(expectedNumElements); } public CreatableTopicResultCollection(Iterator<CreatableTopicResult> iterator) { super(iterator); } public CreatableTopicResult find(String name) { CreatableTopicResult _key = new CreatableTopicResult(); _key.setName(name); return find(_key); } public List<CreatableTopicResult> findAll(String name) { CreatableTopicResult _key = new CreatableTopicResult(); _key.setName(name); return findAll(_key); } public CreatableTopicResultCollection duplicate() { CreatableTopicResultCollection _duplicate = new CreatableTopicResultCollection(size()); for (CreatableTopicResult _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/CreateTopicsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.CreateTopicsResponseData.*; public class CreateTopicsResponseDataJsonConverter { public static CreateTopicsResponseData read(JsonNode _node, short _version) { CreateTopicsResponseData _object = new CreateTopicsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { if (_version >= 2) { throw new RuntimeException("CreateTopicsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = 0; } } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "CreateTopicsResponseData"); } JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("CreateTopicsResponseData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("CreateTopicsResponseData expected a JSON array, but got " + _node.getNodeType()); } CreatableTopicResultCollection _collection = new CreatableTopicResultCollection(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(CreatableTopicResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(CreateTopicsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_version >= 2) { _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); } ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (CreatableTopicResult _element : _object.topics) { _topicsArray.add(CreatableTopicResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); return _node; } public static JsonNode write(CreateTopicsResponseData _object, short _version) { return write(_object, _version, true); } public static class CreatableTopicConfigsJsonConverter { public static CreatableTopicConfigs read(JsonNode _node, short _version) { CreatableTopicConfigs _object = new CreatableTopicConfigs(); if (_version < 5) { throw new UnsupportedVersionException("Can't read version " + _version + " of CreatableTopicConfigs"); } JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("CreatableTopicConfigs: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("CreatableTopicConfigs expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _valueNode = _node.get("value"); if (_valueNode == null) { throw new RuntimeException("CreatableTopicConfigs: unable to locate field 'value', which is mandatory in version " + _version); } else { if (_valueNode.isNull()) { _object.value = null; } else { if (!_valueNode.isTextual()) { throw new RuntimeException("CreatableTopicConfigs expected a string type, but got " + _node.getNodeType()); } _object.value = _valueNode.asText(); } } JsonNode _readOnlyNode = _node.get("readOnly"); if (_readOnlyNode == null) { throw new RuntimeException("CreatableTopicConfigs: unable to locate field 'readOnly', which is mandatory in version " + _version); } else { if (!_readOnlyNode.isBoolean()) { throw new RuntimeException("CreatableTopicConfigs expected Boolean type, but got " + _node.getNodeType()); } _object.readOnly = _readOnlyNode.asBoolean(); } JsonNode _configSourceNode = _node.get("configSource"); if (_configSourceNode == null) { throw new RuntimeException("CreatableTopicConfigs: unable to locate field 'configSource', which is mandatory in version " + _version); } else { _object.configSource = MessageUtil.jsonNodeToByte(_configSourceNode, "CreatableTopicConfigs"); } JsonNode _isSensitiveNode = _node.get("isSensitive"); if (_isSensitiveNode == null) { throw new RuntimeException("CreatableTopicConfigs: unable to locate field 'isSensitive', which is mandatory in version " + _version); } else { if (!_isSensitiveNode.isBoolean()) { throw new RuntimeException("CreatableTopicConfigs expected Boolean type, but got " + _node.getNodeType()); } _object.isSensitive = _isSensitiveNode.asBoolean(); } return _object; } public static JsonNode write(CreatableTopicConfigs _object, short _version, boolean _serializeRecords) { if (_version < 5) { throw new UnsupportedVersionException("Can't write version " + _version + " of CreatableTopicConfigs"); } ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); if (_object.value == null) { _node.set("value", NullNode.instance); } else { _node.set("value", new TextNode(_object.value)); } _node.set("readOnly", BooleanNode.valueOf(_object.readOnly)); _node.set("configSource", new ShortNode(_object.configSource)); _node.set("isSensitive", BooleanNode.valueOf(_object.isSensitive)); return _node; } public static JsonNode write(CreatableTopicConfigs _object, short _version) { return write(_object, _version, true); } } public static class CreatableTopicResultJsonConverter { public static CreatableTopicResult read(JsonNode _node, short _version) { CreatableTopicResult _object = new CreatableTopicResult(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("CreatableTopicResult: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("CreatableTopicResult expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _topicIdNode = _node.get("topicId"); if (_topicIdNode == null) { if (_version >= 7) { throw new RuntimeException("CreatableTopicResult: unable to locate field 'topicId', which is mandatory in version " + _version); } else { _object.topicId = Uuid.ZERO_UUID; } } else { if (!_topicIdNode.isTextual()) { throw new RuntimeException("CreatableTopicResult expected a JSON string type, but got " + _node.getNodeType()); } _object.topicId = Uuid.fromString(_topicIdNode.asText()); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("CreatableTopicResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "CreatableTopicResult"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { if (_version >= 1) { throw new RuntimeException("CreatableTopicResult: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { _object.errorMessage = ""; } } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("CreatableTopicResult expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _topicConfigErrorCodeNode = _node.get("topicConfigErrorCode"); if (_topicConfigErrorCodeNode == null) { _object.topicConfigErrorCode = (short) 0; } else { _object.topicConfigErrorCode = MessageUtil.jsonNodeToShort(_topicConfigErrorCodeNode, "CreatableTopicResult"); } JsonNode _numPartitionsNode = _node.get("numPartitions"); if (_numPartitionsNode == null) { if (_version >= 5) { throw new RuntimeException("CreatableTopicResult: unable to locate field 'numPartitions', which is mandatory in version " + _version); } else { _object.numPartitions = -1; } } else { _object.numPartitions = MessageUtil.jsonNodeToInt(_numPartitionsNode, "CreatableTopicResult"); } JsonNode _replicationFactorNode = _node.get("replicationFactor"); if (_replicationFactorNode == null) { if (_version >= 5) { throw new RuntimeException("CreatableTopicResult: unable to locate field 'replicationFactor', which is mandatory in version " + _version); } else { _object.replicationFactor = (short) -1; } } else { _object.replicationFactor = MessageUtil.jsonNodeToShort(_replicationFactorNode, "CreatableTopicResult"); } JsonNode _configsNode = _node.get("configs"); if (_configsNode == null) { if (_version >= 5) { throw new RuntimeException("CreatableTopicResult: unable to locate field 'configs', which is mandatory in version " + _version); } else { _object.configs = new ArrayList<CreatableTopicConfigs>(0); } } else { if (_configsNode.isNull()) { _object.configs = null; } else { if (!_configsNode.isArray()) { throw new RuntimeException("CreatableTopicResult expected a JSON array, but got " + _node.getNodeType()); } ArrayList<CreatableTopicConfigs> _collection = new ArrayList<CreatableTopicConfigs>(_configsNode.size()); _object.configs = _collection; for (JsonNode _element : _configsNode) { _collection.add(CreatableTopicConfigsJsonConverter.read(_element, _version)); } } } return _object; } public static JsonNode write(CreatableTopicResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); if (_version >= 7) { _node.set("topicId", new TextNode(_object.topicId.toString())); } _node.set("errorCode", new ShortNode(_object.errorCode)); if (_version >= 1) { if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } } if (_version >= 5) { if (_object.topicConfigErrorCode != (short) 0) { _node.set("topicConfigErrorCode", new ShortNode(_object.topicConfigErrorCode)); } } if (_version >= 5) { _node.set("numPartitions", new IntNode(_object.numPartitions)); } if (_version >= 5) { _node.set("replicationFactor", new ShortNode(_object.replicationFactor)); } if (_version >= 5) { if (_object.configs == null) { _node.set("configs", NullNode.instance); } else { ArrayNode _configsArray = new ArrayNode(JsonNodeFactory.instance); for (CreatableTopicConfigs _element : _object.configs) { _configsArray.add(CreatableTopicConfigsJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("configs", _configsArray); } } return _node; } public static JsonNode write(CreatableTopicResult _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DefaultPrincipalData.java
/* * 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.protocol.ApiMessage; 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.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 DefaultPrincipalData implements ApiMessage { String type; String name; boolean tokenAuthenticated; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("type", Type.COMPACT_STRING, "The principal type"), new Field("name", Type.COMPACT_STRING, "The principal name"), new Field("token_authenticated", Type.BOOLEAN, "Whether the principal was authenticated by a delegation token on the forwarding broker."), 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 DefaultPrincipalData(Readable _readable, short _version) { read(_readable, _version); } public DefaultPrincipalData() { this.type = ""; this.name = ""; this.tokenAuthenticated = false; } @Override public short apiKey() { return -1; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field type was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field type had invalid length " + length); } else { this.type = _readable.readString(length); } } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } this.tokenAuthenticated = _readable.readByte() != 0; 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; { byte[] _stringBytes = _cache.getSerializedValue(type); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(name); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeByte(tokenAuthenticated ? (byte) 1 : (byte) 0); 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; { byte[] _stringBytes = type.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'type' field is too long to be serialized"); } _cache.cacheSerializedValue(type, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _size.addBytes(1); 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 DefaultPrincipalData)) return false; DefaultPrincipalData other = (DefaultPrincipalData) obj; if (this.type == null) { if (other.type != null) return false; } else { if (!this.type.equals(other.type)) return false; } if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (tokenAuthenticated != other.tokenAuthenticated) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (type == null ? 0 : type.hashCode()); hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + (tokenAuthenticated ? 1231 : 1237); return hashCode; } @Override public DefaultPrincipalData duplicate() { DefaultPrincipalData _duplicate = new DefaultPrincipalData(); _duplicate.type = type; _duplicate.name = name; _duplicate.tokenAuthenticated = tokenAuthenticated; return _duplicate; } @Override public String toString() { return "DefaultPrincipalData(" + "type=" + ((type == null) ? "null" : "'" + type.toString() + "'") + ", name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", tokenAuthenticated=" + (tokenAuthenticated ? "true" : "false") + ")"; } public String type() { return this.type; } public String name() { return this.name; } public boolean tokenAuthenticated() { return this.tokenAuthenticated; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DefaultPrincipalData setType(String v) { this.type = v; return this; } public DefaultPrincipalData setName(String v) { this.name = v; return this; } public DefaultPrincipalData setTokenAuthenticated(boolean v) { this.tokenAuthenticated = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DefaultPrincipalDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import static org.apache.kafka.common.message.DefaultPrincipalData.*; public class DefaultPrincipalDataJsonConverter { public static DefaultPrincipalData read(JsonNode _node, short _version) { DefaultPrincipalData _object = new DefaultPrincipalData(); JsonNode _typeNode = _node.get("type"); if (_typeNode == null) { throw new RuntimeException("DefaultPrincipalData: unable to locate field 'type', which is mandatory in version " + _version); } else { if (!_typeNode.isTextual()) { throw new RuntimeException("DefaultPrincipalData expected a string type, but got " + _node.getNodeType()); } _object.type = _typeNode.asText(); } JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("DefaultPrincipalData: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("DefaultPrincipalData expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _tokenAuthenticatedNode = _node.get("tokenAuthenticated"); if (_tokenAuthenticatedNode == null) { throw new RuntimeException("DefaultPrincipalData: unable to locate field 'tokenAuthenticated', which is mandatory in version " + _version); } else { if (!_tokenAuthenticatedNode.isBoolean()) { throw new RuntimeException("DefaultPrincipalData expected Boolean type, but got " + _node.getNodeType()); } _object.tokenAuthenticated = _tokenAuthenticatedNode.asBoolean(); } return _object; } public static JsonNode write(DefaultPrincipalData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("type", new TextNode(_object.type)); _node.set("name", new TextNode(_object.name)); _node.set("tokenAuthenticated", BooleanNode.valueOf(_object.tokenAuthenticated)); return _node; } public static JsonNode write(DefaultPrincipalData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteAclsRequestData.java
/* * 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 DeleteAclsRequestData implements ApiMessage { List<DeleteAclsFilter> filters; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("filters", new ArrayOf(DeleteAclsFilter.SCHEMA_0), "The filters to use when deleting ACLs.") ); public static final Schema SCHEMA_1 = new Schema( new Field("filters", new ArrayOf(DeleteAclsFilter.SCHEMA_1), "The filters to use when deleting ACLs.") ); public static final Schema SCHEMA_2 = new Schema( new Field("filters", new CompactArrayOf(DeleteAclsFilter.SCHEMA_2), "The filters to use when deleting ACLs."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DeleteAclsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DeleteAclsRequestData() { this.filters = new ArrayList<DeleteAclsFilter>(0); } @Override public short apiKey() { return 31; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field filters 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<DeleteAclsFilter> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteAclsFilter(_readable, _version)); } this.filters = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field filters 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<DeleteAclsFilter> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteAclsFilter(_readable, _version)); } this.filters = 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; if (_version >= 2) { _writable.writeUnsignedVarint(filters.size() + 1); for (DeleteAclsFilter filtersElement : filters) { filtersElement.write(_writable, _cache, _version); } } else { _writable.writeInt(filters.size()); for (DeleteAclsFilter filtersElement : filters) { filtersElement.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; { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(filters.size() + 1)); } else { _size.addBytes(4); } for (DeleteAclsFilter filtersElement : filters) { filtersElement.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 DeleteAclsRequestData)) return false; DeleteAclsRequestData other = (DeleteAclsRequestData) obj; if (this.filters == null) { if (other.filters != null) return false; } else { if (!this.filters.equals(other.filters)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (filters == null ? 0 : filters.hashCode()); return hashCode; } @Override public DeleteAclsRequestData duplicate() { DeleteAclsRequestData _duplicate = new DeleteAclsRequestData(); ArrayList<DeleteAclsFilter> newFilters = new ArrayList<DeleteAclsFilter>(filters.size()); for (DeleteAclsFilter _element : filters) { newFilters.add(_element.duplicate()); } _duplicate.filters = newFilters; return _duplicate; } @Override public String toString() { return "DeleteAclsRequestData(" + "filters=" + MessageUtil.deepToString(filters.iterator()) + ")"; } public List<DeleteAclsFilter> filters() { return this.filters; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteAclsRequestData setFilters(List<DeleteAclsFilter> v) { this.filters = v; return this; } public static class DeleteAclsFilter implements Message { byte resourceTypeFilter; String resourceNameFilter; byte patternTypeFilter; String principalFilter; String hostFilter; byte operation; byte permissionType; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("resource_type_filter", Type.INT8, "The resource type."), new Field("resource_name_filter", Type.NULLABLE_STRING, "The resource name."), new Field("principal_filter", Type.NULLABLE_STRING, "The principal filter, or null to accept all principals."), new Field("host_filter", Type.NULLABLE_STRING, "The host filter, or null to accept all hosts."), new Field("operation", Type.INT8, "The ACL operation."), new Field("permission_type", Type.INT8, "The permission type.") ); public static final Schema SCHEMA_1 = new Schema( new Field("resource_type_filter", Type.INT8, "The resource type."), new Field("resource_name_filter", Type.NULLABLE_STRING, "The resource name."), new Field("pattern_type_filter", Type.INT8, "The pattern type."), new Field("principal_filter", Type.NULLABLE_STRING, "The principal filter, or null to accept all principals."), new Field("host_filter", Type.NULLABLE_STRING, "The host filter, or null to accept all hosts."), new Field("operation", Type.INT8, "The ACL operation."), new Field("permission_type", Type.INT8, "The permission type.") ); public static final Schema SCHEMA_2 = new Schema( new Field("resource_type_filter", Type.INT8, "The resource type."), new Field("resource_name_filter", Type.COMPACT_NULLABLE_STRING, "The resource name."), new Field("pattern_type_filter", Type.INT8, "The pattern type."), new Field("principal_filter", Type.COMPACT_NULLABLE_STRING, "The principal filter, or null to accept all principals."), new Field("host_filter", Type.COMPACT_NULLABLE_STRING, "The host filter, or null to accept all hosts."), new Field("operation", Type.INT8, "The ACL operation."), new Field("permission_type", Type.INT8, "The permission type."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DeleteAclsFilter(Readable _readable, short _version) { read(_readable, _version); } public DeleteAclsFilter() { this.resourceTypeFilter = (byte) 0; this.resourceNameFilter = ""; this.patternTypeFilter = (byte) 3; this.principalFilter = ""; this.hostFilter = ""; this.operation = (byte) 0; this.permissionType = (byte) 0; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteAclsFilter"); } this.resourceTypeFilter = _readable.readByte(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.resourceNameFilter = null; } else if (length > 0x7fff) { throw new RuntimeException("string field resourceNameFilter had invalid length " + length); } else { this.resourceNameFilter = _readable.readString(length); } } if (_version >= 1) { this.patternTypeFilter = _readable.readByte(); } else { this.patternTypeFilter = (byte) 3; } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.principalFilter = null; } else if (length > 0x7fff) { throw new RuntimeException("string field principalFilter had invalid length " + length); } else { this.principalFilter = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.hostFilter = null; } else if (length > 0x7fff) { throw new RuntimeException("string field hostFilter had invalid length " + length); } else { this.hostFilter = _readable.readString(length); } } this.operation = _readable.readByte(); this.permissionType = _readable.readByte(); 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.writeByte(resourceTypeFilter); if (resourceNameFilter == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(resourceNameFilter); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 1) { _writable.writeByte(patternTypeFilter); } else { if (this.patternTypeFilter != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default patternTypeFilter at version " + _version); } } if (principalFilter == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(principalFilter); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (hostFilter == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(hostFilter); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(operation); _writable.writeByte(permissionType); 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeleteAclsFilter"); } _size.addBytes(1); if (resourceNameFilter == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = resourceNameFilter.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'resourceNameFilter' field is too long to be serialized"); } _cache.cacheSerializedValue(resourceNameFilter, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 1) { _size.addBytes(1); } if (principalFilter == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = principalFilter.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalFilter' field is too long to be serialized"); } _cache.cacheSerializedValue(principalFilter, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (hostFilter == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = hostFilter.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'hostFilter' field is too long to be serialized"); } _cache.cacheSerializedValue(hostFilter, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); _size.addBytes(1); 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 DeleteAclsFilter)) return false; DeleteAclsFilter other = (DeleteAclsFilter) obj; if (resourceTypeFilter != other.resourceTypeFilter) return false; if (this.resourceNameFilter == null) { if (other.resourceNameFilter != null) return false; } else { if (!this.resourceNameFilter.equals(other.resourceNameFilter)) return false; } if (patternTypeFilter != other.patternTypeFilter) return false; if (this.principalFilter == null) { if (other.principalFilter != null) return false; } else { if (!this.principalFilter.equals(other.principalFilter)) return false; } if (this.hostFilter == null) { if (other.hostFilter != null) return false; } else { if (!this.hostFilter.equals(other.hostFilter)) return false; } if (operation != other.operation) return false; if (permissionType != other.permissionType) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + resourceTypeFilter; hashCode = 31 * hashCode + (resourceNameFilter == null ? 0 : resourceNameFilter.hashCode()); hashCode = 31 * hashCode + patternTypeFilter; hashCode = 31 * hashCode + (principalFilter == null ? 0 : principalFilter.hashCode()); hashCode = 31 * hashCode + (hostFilter == null ? 0 : hostFilter.hashCode()); hashCode = 31 * hashCode + operation; hashCode = 31 * hashCode + permissionType; return hashCode; } @Override public DeleteAclsFilter duplicate() { DeleteAclsFilter _duplicate = new DeleteAclsFilter(); _duplicate.resourceTypeFilter = resourceTypeFilter; if (resourceNameFilter == null) { _duplicate.resourceNameFilter = null; } else { _duplicate.resourceNameFilter = resourceNameFilter; } _duplicate.patternTypeFilter = patternTypeFilter; if (principalFilter == null) { _duplicate.principalFilter = null; } else { _duplicate.principalFilter = principalFilter; } if (hostFilter == null) { _duplicate.hostFilter = null; } else { _duplicate.hostFilter = hostFilter; } _duplicate.operation = operation; _duplicate.permissionType = permissionType; return _duplicate; } @Override public String toString() { return "DeleteAclsFilter(" + "resourceTypeFilter=" + resourceTypeFilter + ", resourceNameFilter=" + ((resourceNameFilter == null) ? "null" : "'" + resourceNameFilter.toString() + "'") + ", patternTypeFilter=" + patternTypeFilter + ", principalFilter=" + ((principalFilter == null) ? "null" : "'" + principalFilter.toString() + "'") + ", hostFilter=" + ((hostFilter == null) ? "null" : "'" + hostFilter.toString() + "'") + ", operation=" + operation + ", permissionType=" + permissionType + ")"; } public byte resourceTypeFilter() { return this.resourceTypeFilter; } public String resourceNameFilter() { return this.resourceNameFilter; } public byte patternTypeFilter() { return this.patternTypeFilter; } public String principalFilter() { return this.principalFilter; } public String hostFilter() { return this.hostFilter; } public byte operation() { return this.operation; } public byte permissionType() { return this.permissionType; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteAclsFilter setResourceTypeFilter(byte v) { this.resourceTypeFilter = v; return this; } public DeleteAclsFilter setResourceNameFilter(String v) { this.resourceNameFilter = v; return this; } public DeleteAclsFilter setPatternTypeFilter(byte v) { this.patternTypeFilter = v; return this; } public DeleteAclsFilter setPrincipalFilter(String v) { this.principalFilter = v; return this; } public DeleteAclsFilter setHostFilter(String v) { this.hostFilter = v; return this; } public DeleteAclsFilter setOperation(byte v) { this.operation = v; return this; } public DeleteAclsFilter setPermissionType(byte v) { this.permissionType = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteAclsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DeleteAclsRequestData.*; public class DeleteAclsRequestDataJsonConverter { public static DeleteAclsRequestData read(JsonNode _node, short _version) { DeleteAclsRequestData _object = new DeleteAclsRequestData(); JsonNode _filtersNode = _node.get("filters"); if (_filtersNode == null) { throw new RuntimeException("DeleteAclsRequestData: unable to locate field 'filters', which is mandatory in version " + _version); } else { if (!_filtersNode.isArray()) { throw new RuntimeException("DeleteAclsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DeleteAclsFilter> _collection = new ArrayList<DeleteAclsFilter>(_filtersNode.size()); _object.filters = _collection; for (JsonNode _element : _filtersNode) { _collection.add(DeleteAclsFilterJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DeleteAclsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _filtersArray = new ArrayNode(JsonNodeFactory.instance); for (DeleteAclsFilter _element : _object.filters) { _filtersArray.add(DeleteAclsFilterJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("filters", _filtersArray); return _node; } public static JsonNode write(DeleteAclsRequestData _object, short _version) { return write(_object, _version, true); } public static class DeleteAclsFilterJsonConverter { public static DeleteAclsFilter read(JsonNode _node, short _version) { DeleteAclsFilter _object = new DeleteAclsFilter(); JsonNode _resourceTypeFilterNode = _node.get("resourceTypeFilter"); if (_resourceTypeFilterNode == null) { throw new RuntimeException("DeleteAclsFilter: unable to locate field 'resourceTypeFilter', which is mandatory in version " + _version); } else { _object.resourceTypeFilter = MessageUtil.jsonNodeToByte(_resourceTypeFilterNode, "DeleteAclsFilter"); } JsonNode _resourceNameFilterNode = _node.get("resourceNameFilter"); if (_resourceNameFilterNode == null) { throw new RuntimeException("DeleteAclsFilter: unable to locate field 'resourceNameFilter', which is mandatory in version " + _version); } else { if (_resourceNameFilterNode.isNull()) { _object.resourceNameFilter = null; } else { if (!_resourceNameFilterNode.isTextual()) { throw new RuntimeException("DeleteAclsFilter expected a string type, but got " + _node.getNodeType()); } _object.resourceNameFilter = _resourceNameFilterNode.asText(); } } JsonNode _patternTypeFilterNode = _node.get("patternTypeFilter"); if (_patternTypeFilterNode == null) { if (_version >= 1) { throw new RuntimeException("DeleteAclsFilter: unable to locate field 'patternTypeFilter', which is mandatory in version " + _version); } else { _object.patternTypeFilter = (byte) 3; } } else { _object.patternTypeFilter = MessageUtil.jsonNodeToByte(_patternTypeFilterNode, "DeleteAclsFilter"); } JsonNode _principalFilterNode = _node.get("principalFilter"); if (_principalFilterNode == null) { throw new RuntimeException("DeleteAclsFilter: unable to locate field 'principalFilter', which is mandatory in version " + _version); } else { if (_principalFilterNode.isNull()) { _object.principalFilter = null; } else { if (!_principalFilterNode.isTextual()) { throw new RuntimeException("DeleteAclsFilter expected a string type, but got " + _node.getNodeType()); } _object.principalFilter = _principalFilterNode.asText(); } } JsonNode _hostFilterNode = _node.get("hostFilter"); if (_hostFilterNode == null) { throw new RuntimeException("DeleteAclsFilter: unable to locate field 'hostFilter', which is mandatory in version " + _version); } else { if (_hostFilterNode.isNull()) { _object.hostFilter = null; } else { if (!_hostFilterNode.isTextual()) { throw new RuntimeException("DeleteAclsFilter expected a string type, but got " + _node.getNodeType()); } _object.hostFilter = _hostFilterNode.asText(); } } JsonNode _operationNode = _node.get("operation"); if (_operationNode == null) { throw new RuntimeException("DeleteAclsFilter: unable to locate field 'operation', which is mandatory in version " + _version); } else { _object.operation = MessageUtil.jsonNodeToByte(_operationNode, "DeleteAclsFilter"); } JsonNode _permissionTypeNode = _node.get("permissionType"); if (_permissionTypeNode == null) { throw new RuntimeException("DeleteAclsFilter: unable to locate field 'permissionType', which is mandatory in version " + _version); } else { _object.permissionType = MessageUtil.jsonNodeToByte(_permissionTypeNode, "DeleteAclsFilter"); } return _object; } public static JsonNode write(DeleteAclsFilter _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("resourceTypeFilter", new ShortNode(_object.resourceTypeFilter)); if (_object.resourceNameFilter == null) { _node.set("resourceNameFilter", NullNode.instance); } else { _node.set("resourceNameFilter", new TextNode(_object.resourceNameFilter)); } if (_version >= 1) { _node.set("patternTypeFilter", new ShortNode(_object.patternTypeFilter)); } else { if (_object.patternTypeFilter != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default patternTypeFilter at version " + _version); } } if (_object.principalFilter == null) { _node.set("principalFilter", NullNode.instance); } else { _node.set("principalFilter", new TextNode(_object.principalFilter)); } if (_object.hostFilter == null) { _node.set("hostFilter", NullNode.instance); } else { _node.set("hostFilter", new TextNode(_object.hostFilter)); } _node.set("operation", new ShortNode(_object.operation)); _node.set("permissionType", new ShortNode(_object.permissionType)); return _node; } public static JsonNode write(DeleteAclsFilter _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteAclsResponseData.java
/* * 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 DeleteAclsResponseData implements ApiMessage { int throttleTimeMs; List<DeleteAclsFilterResult> filterResults; private List<RawTaggedField> _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("filter_results", new ArrayOf(DeleteAclsFilterResult.SCHEMA_0), "The results for each filter.") ); public static final Schema SCHEMA_1 = 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("filter_results", new ArrayOf(DeleteAclsFilterResult.SCHEMA_1), "The results for each filter.") ); public static final Schema SCHEMA_2 = 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("filter_results", new CompactArrayOf(DeleteAclsFilterResult.SCHEMA_2), "The results for each filter."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DeleteAclsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DeleteAclsResponseData() { this.throttleTimeMs = 0; this.filterResults = new ArrayList<DeleteAclsFilterResult>(0); } @Override public short apiKey() { return 31; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field filterResults 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<DeleteAclsFilterResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteAclsFilterResult(_readable, _version)); } this.filterResults = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field filterResults 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<DeleteAclsFilterResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteAclsFilterResult(_readable, _version)); } this.filterResults = 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.writeInt(throttleTimeMs); if (_version >= 2) { _writable.writeUnsignedVarint(filterResults.size() + 1); for (DeleteAclsFilterResult filterResultsElement : filterResults) { filterResultsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(filterResults.size()); for (DeleteAclsFilterResult filterResultsElement : filterResults) { filterResultsElement.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(4); { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(filterResults.size() + 1)); } else { _size.addBytes(4); } for (DeleteAclsFilterResult filterResultsElement : filterResults) { filterResultsElement.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 DeleteAclsResponseData)) return false; DeleteAclsResponseData other = (DeleteAclsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.filterResults == null) { if (other.filterResults != null) return false; } else { if (!this.filterResults.equals(other.filterResults)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (filterResults == null ? 0 : filterResults.hashCode()); return hashCode; } @Override public DeleteAclsResponseData duplicate() { DeleteAclsResponseData _duplicate = new DeleteAclsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; ArrayList<DeleteAclsFilterResult> newFilterResults = new ArrayList<DeleteAclsFilterResult>(filterResults.size()); for (DeleteAclsFilterResult _element : filterResults) { newFilterResults.add(_element.duplicate()); } _duplicate.filterResults = newFilterResults; return _duplicate; } @Override public String toString() { return "DeleteAclsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", filterResults=" + MessageUtil.deepToString(filterResults.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public List<DeleteAclsFilterResult> filterResults() { return this.filterResults; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteAclsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DeleteAclsResponseData setFilterResults(List<DeleteAclsFilterResult> v) { this.filterResults = v; return this; } public static class DeleteAclsFilterResult implements Message { short errorCode; String errorMessage; List<DeleteAclsMatchingAcl> matchingAcls; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if the filter succeeded."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or null if the filter succeeded."), new Field("matching_acls", new ArrayOf(DeleteAclsMatchingAcl.SCHEMA_0), "The ACLs which matched this filter.") ); public static final Schema SCHEMA_1 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if the filter succeeded."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or null if the filter succeeded."), new Field("matching_acls", new ArrayOf(DeleteAclsMatchingAcl.SCHEMA_1), "The ACLs which matched this filter.") ); public static final Schema SCHEMA_2 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if the filter succeeded."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The error message, or null if the filter succeeded."), new Field("matching_acls", new CompactArrayOf(DeleteAclsMatchingAcl.SCHEMA_2), "The ACLs which matched this filter."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DeleteAclsFilterResult(Readable _readable, short _version) { read(_readable, _version); } public DeleteAclsFilterResult() { this.errorCode = (short) 0; this.errorMessage = ""; this.matchingAcls = new ArrayList<DeleteAclsMatchingAcl>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteAclsFilterResult"); } this.errorCode = _readable.readShort(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field matchingAcls 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<DeleteAclsMatchingAcl> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteAclsMatchingAcl(_readable, _version)); } this.matchingAcls = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field matchingAcls 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<DeleteAclsMatchingAcl> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteAclsMatchingAcl(_readable, _version)); } this.matchingAcls = 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 (errorMessage == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(matchingAcls.size() + 1); for (DeleteAclsMatchingAcl matchingAclsElement : matchingAcls) { matchingAclsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(matchingAcls.size()); for (DeleteAclsMatchingAcl matchingAclsElement : matchingAcls) { matchingAclsElement.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; if (_version > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeleteAclsFilterResult"); } _size.addBytes(2); if (errorMessage == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(matchingAcls.size() + 1)); } else { _size.addBytes(4); } for (DeleteAclsMatchingAcl matchingAclsElement : matchingAcls) { matchingAclsElement.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 DeleteAclsFilterResult)) return false; DeleteAclsFilterResult other = (DeleteAclsFilterResult) obj; 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.matchingAcls == null) { if (other.matchingAcls != null) return false; } else { if (!this.matchingAcls.equals(other.matchingAcls)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode()); hashCode = 31 * hashCode + (matchingAcls == null ? 0 : matchingAcls.hashCode()); return hashCode; } @Override public DeleteAclsFilterResult duplicate() { DeleteAclsFilterResult _duplicate = new DeleteAclsFilterResult(); _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } ArrayList<DeleteAclsMatchingAcl> newMatchingAcls = new ArrayList<DeleteAclsMatchingAcl>(matchingAcls.size()); for (DeleteAclsMatchingAcl _element : matchingAcls) { newMatchingAcls.add(_element.duplicate()); } _duplicate.matchingAcls = newMatchingAcls; return _duplicate; } @Override public String toString() { return "DeleteAclsFilterResult(" + "errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", matchingAcls=" + MessageUtil.deepToString(matchingAcls.iterator()) + ")"; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public List<DeleteAclsMatchingAcl> matchingAcls() { return this.matchingAcls; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteAclsFilterResult setErrorCode(short v) { this.errorCode = v; return this; } public DeleteAclsFilterResult setErrorMessage(String v) { this.errorMessage = v; return this; } public DeleteAclsFilterResult setMatchingAcls(List<DeleteAclsMatchingAcl> v) { this.matchingAcls = v; return this; } } public static class DeleteAclsMatchingAcl implements Message { short errorCode; String errorMessage; byte resourceType; String resourceName; byte patternType; String principal; String host; byte operation; byte permissionType; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The deletion error code, or 0 if the deletion succeeded."), new Field("error_message", Type.NULLABLE_STRING, "The deletion error message, or null if the deletion succeeded."), new Field("resource_type", Type.INT8, "The ACL resource type."), new Field("resource_name", Type.STRING, "The ACL resource name."), new Field("principal", Type.STRING, "The ACL principal."), new Field("host", Type.STRING, "The ACL host."), new Field("operation", Type.INT8, "The ACL operation."), new Field("permission_type", Type.INT8, "The ACL permission type.") ); public static final Schema SCHEMA_1 = new Schema( new Field("error_code", Type.INT16, "The deletion error code, or 0 if the deletion succeeded."), new Field("error_message", Type.NULLABLE_STRING, "The deletion error message, or null if the deletion succeeded."), new Field("resource_type", Type.INT8, "The ACL resource type."), new Field("resource_name", Type.STRING, "The ACL resource name."), new Field("pattern_type", Type.INT8, "The ACL resource pattern type."), new Field("principal", Type.STRING, "The ACL principal."), new Field("host", Type.STRING, "The ACL host."), new Field("operation", Type.INT8, "The ACL operation."), new Field("permission_type", Type.INT8, "The ACL permission type.") ); public static final Schema SCHEMA_2 = new Schema( new Field("error_code", Type.INT16, "The deletion error code, or 0 if the deletion succeeded."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The deletion error message, or null if the deletion succeeded."), new Field("resource_type", Type.INT8, "The ACL resource type."), new Field("resource_name", Type.COMPACT_STRING, "The ACL resource name."), new Field("pattern_type", Type.INT8, "The ACL resource pattern type."), new Field("principal", Type.COMPACT_STRING, "The ACL principal."), new Field("host", Type.COMPACT_STRING, "The ACL host."), new Field("operation", Type.INT8, "The ACL operation."), new Field("permission_type", Type.INT8, "The ACL permission type."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DeleteAclsMatchingAcl(Readable _readable, short _version) { read(_readable, _version); } public DeleteAclsMatchingAcl() { this.errorCode = (short) 0; this.errorMessage = ""; this.resourceType = (byte) 0; this.resourceName = ""; this.patternType = (byte) 3; this.principal = ""; this.host = ""; this.operation = (byte) 0; this.permissionType = (byte) 0; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteAclsMatchingAcl"); } this.errorCode = _readable.readShort(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } this.resourceType = _readable.readByte(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field resourceName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field resourceName had invalid length " + length); } else { this.resourceName = _readable.readString(length); } } if (_version >= 1) { this.patternType = _readable.readByte(); } else { this.patternType = (byte) 3; } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principal was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principal had invalid length " + length); } else { this.principal = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field host was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field host had invalid length " + length); } else { this.host = _readable.readString(length); } } this.operation = _readable.readByte(); this.permissionType = _readable.readByte(); 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 (errorMessage == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(resourceType); { byte[] _stringBytes = _cache.getSerializedValue(resourceName); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 1) { _writable.writeByte(patternType); } else { if (this.patternType != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default patternType at version " + _version); } } { byte[] _stringBytes = _cache.getSerializedValue(principal); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(host); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(operation); _writable.writeByte(permissionType); 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeleteAclsMatchingAcl"); } _size.addBytes(2); if (errorMessage == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); { byte[] _stringBytes = resourceName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'resourceName' field is too long to be serialized"); } _cache.cacheSerializedValue(resourceName, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 1) { _size.addBytes(1); } { byte[] _stringBytes = principal.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principal' field is too long to be serialized"); } _cache.cacheSerializedValue(principal, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = host.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'host' field is too long to be serialized"); } _cache.cacheSerializedValue(host, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); _size.addBytes(1); 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 DeleteAclsMatchingAcl)) return false; DeleteAclsMatchingAcl other = (DeleteAclsMatchingAcl) obj; 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 (resourceType != other.resourceType) return false; if (this.resourceName == null) { if (other.resourceName != null) return false; } else { if (!this.resourceName.equals(other.resourceName)) return false; } if (patternType != other.patternType) return false; if (this.principal == null) { if (other.principal != null) return false; } else { if (!this.principal.equals(other.principal)) return false; } if (this.host == null) { if (other.host != null) return false; } else { if (!this.host.equals(other.host)) return false; } if (operation != other.operation) return false; if (permissionType != other.permissionType) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode()); hashCode = 31 * hashCode + resourceType; hashCode = 31 * hashCode + (resourceName == null ? 0 : resourceName.hashCode()); hashCode = 31 * hashCode + patternType; hashCode = 31 * hashCode + (principal == null ? 0 : principal.hashCode()); hashCode = 31 * hashCode + (host == null ? 0 : host.hashCode()); hashCode = 31 * hashCode + operation; hashCode = 31 * hashCode + permissionType; return hashCode; } @Override public DeleteAclsMatchingAcl duplicate() { DeleteAclsMatchingAcl _duplicate = new DeleteAclsMatchingAcl(); _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } _duplicate.resourceType = resourceType; _duplicate.resourceName = resourceName; _duplicate.patternType = patternType; _duplicate.principal = principal; _duplicate.host = host; _duplicate.operation = operation; _duplicate.permissionType = permissionType; return _duplicate; } @Override public String toString() { return "DeleteAclsMatchingAcl(" + "errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", resourceType=" + resourceType + ", resourceName=" + ((resourceName == null) ? "null" : "'" + resourceName.toString() + "'") + ", patternType=" + patternType + ", principal=" + ((principal == null) ? "null" : "'" + principal.toString() + "'") + ", host=" + ((host == null) ? "null" : "'" + host.toString() + "'") + ", operation=" + operation + ", permissionType=" + permissionType + ")"; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public byte resourceType() { return this.resourceType; } public String resourceName() { return this.resourceName; } public byte patternType() { return this.patternType; } public String principal() { return this.principal; } public String host() { return this.host; } public byte operation() { return this.operation; } public byte permissionType() { return this.permissionType; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteAclsMatchingAcl setErrorCode(short v) { this.errorCode = v; return this; } public DeleteAclsMatchingAcl setErrorMessage(String v) { this.errorMessage = v; return this; } public DeleteAclsMatchingAcl setResourceType(byte v) { this.resourceType = v; return this; } public DeleteAclsMatchingAcl setResourceName(String v) { this.resourceName = v; return this; } public DeleteAclsMatchingAcl setPatternType(byte v) { this.patternType = v; return this; } public DeleteAclsMatchingAcl setPrincipal(String v) { this.principal = v; return this; } public DeleteAclsMatchingAcl setHost(String v) { this.host = v; return this; } public DeleteAclsMatchingAcl setOperation(byte v) { this.operation = v; return this; } public DeleteAclsMatchingAcl setPermissionType(byte v) { this.permissionType = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteAclsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DeleteAclsResponseData.*; public class DeleteAclsResponseDataJsonConverter { public static DeleteAclsResponseData read(JsonNode _node, short _version) { DeleteAclsResponseData _object = new DeleteAclsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DeleteAclsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DeleteAclsResponseData"); } JsonNode _filterResultsNode = _node.get("filterResults"); if (_filterResultsNode == null) { throw new RuntimeException("DeleteAclsResponseData: unable to locate field 'filterResults', which is mandatory in version " + _version); } else { if (!_filterResultsNode.isArray()) { throw new RuntimeException("DeleteAclsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DeleteAclsFilterResult> _collection = new ArrayList<DeleteAclsFilterResult>(_filterResultsNode.size()); _object.filterResults = _collection; for (JsonNode _element : _filterResultsNode) { _collection.add(DeleteAclsFilterResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DeleteAclsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); ArrayNode _filterResultsArray = new ArrayNode(JsonNodeFactory.instance); for (DeleteAclsFilterResult _element : _object.filterResults) { _filterResultsArray.add(DeleteAclsFilterResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("filterResults", _filterResultsArray); return _node; } public static JsonNode write(DeleteAclsResponseData _object, short _version) { return write(_object, _version, true); } public static class DeleteAclsFilterResultJsonConverter { public static DeleteAclsFilterResult read(JsonNode _node, short _version) { DeleteAclsFilterResult _object = new DeleteAclsFilterResult(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DeleteAclsFilterResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DeleteAclsFilterResult"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("DeleteAclsFilterResult: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DeleteAclsFilterResult expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _matchingAclsNode = _node.get("matchingAcls"); if (_matchingAclsNode == null) { throw new RuntimeException("DeleteAclsFilterResult: unable to locate field 'matchingAcls', which is mandatory in version " + _version); } else { if (!_matchingAclsNode.isArray()) { throw new RuntimeException("DeleteAclsFilterResult expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DeleteAclsMatchingAcl> _collection = new ArrayList<DeleteAclsMatchingAcl>(_matchingAclsNode.size()); _object.matchingAcls = _collection; for (JsonNode _element : _matchingAclsNode) { _collection.add(DeleteAclsMatchingAclJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DeleteAclsFilterResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } ArrayNode _matchingAclsArray = new ArrayNode(JsonNodeFactory.instance); for (DeleteAclsMatchingAcl _element : _object.matchingAcls) { _matchingAclsArray.add(DeleteAclsMatchingAclJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("matchingAcls", _matchingAclsArray); return _node; } public static JsonNode write(DeleteAclsFilterResult _object, short _version) { return write(_object, _version, true); } } public static class DeleteAclsMatchingAclJsonConverter { public static DeleteAclsMatchingAcl read(JsonNode _node, short _version) { DeleteAclsMatchingAcl _object = new DeleteAclsMatchingAcl(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DeleteAclsMatchingAcl"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DeleteAclsMatchingAcl expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _resourceTypeNode = _node.get("resourceType"); if (_resourceTypeNode == null) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'resourceType', which is mandatory in version " + _version); } else { _object.resourceType = MessageUtil.jsonNodeToByte(_resourceTypeNode, "DeleteAclsMatchingAcl"); } JsonNode _resourceNameNode = _node.get("resourceName"); if (_resourceNameNode == null) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'resourceName', which is mandatory in version " + _version); } else { if (!_resourceNameNode.isTextual()) { throw new RuntimeException("DeleteAclsMatchingAcl expected a string type, but got " + _node.getNodeType()); } _object.resourceName = _resourceNameNode.asText(); } JsonNode _patternTypeNode = _node.get("patternType"); if (_patternTypeNode == null) { if (_version >= 1) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'patternType', which is mandatory in version " + _version); } else { _object.patternType = (byte) 3; } } else { _object.patternType = MessageUtil.jsonNodeToByte(_patternTypeNode, "DeleteAclsMatchingAcl"); } JsonNode _principalNode = _node.get("principal"); if (_principalNode == null) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'principal', which is mandatory in version " + _version); } else { if (!_principalNode.isTextual()) { throw new RuntimeException("DeleteAclsMatchingAcl expected a string type, but got " + _node.getNodeType()); } _object.principal = _principalNode.asText(); } JsonNode _hostNode = _node.get("host"); if (_hostNode == null) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'host', which is mandatory in version " + _version); } else { if (!_hostNode.isTextual()) { throw new RuntimeException("DeleteAclsMatchingAcl expected a string type, but got " + _node.getNodeType()); } _object.host = _hostNode.asText(); } JsonNode _operationNode = _node.get("operation"); if (_operationNode == null) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'operation', which is mandatory in version " + _version); } else { _object.operation = MessageUtil.jsonNodeToByte(_operationNode, "DeleteAclsMatchingAcl"); } JsonNode _permissionTypeNode = _node.get("permissionType"); if (_permissionTypeNode == null) { throw new RuntimeException("DeleteAclsMatchingAcl: unable to locate field 'permissionType', which is mandatory in version " + _version); } else { _object.permissionType = MessageUtil.jsonNodeToByte(_permissionTypeNode, "DeleteAclsMatchingAcl"); } return _object; } public static JsonNode write(DeleteAclsMatchingAcl _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } _node.set("resourceType", new ShortNode(_object.resourceType)); _node.set("resourceName", new TextNode(_object.resourceName)); if (_version >= 1) { _node.set("patternType", new ShortNode(_object.patternType)); } else { if (_object.patternType != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default patternType at version " + _version); } } _node.set("principal", new TextNode(_object.principal)); _node.set("host", new TextNode(_object.host)); _node.set("operation", new ShortNode(_object.operation)); _node.set("permissionType", new ShortNode(_object.permissionType)); return _node; } public static JsonNode write(DeleteAclsMatchingAcl _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteGroupsRequestData.java
/* * 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.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 DeleteGroupsRequestData implements ApiMessage { List<String> groupsNames; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("groups_names", new ArrayOf(Type.STRING), "The group names to delete.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("groups_names", new CompactArrayOf(Type.COMPACT_STRING), "The group names to delete."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeleteGroupsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DeleteGroupsRequestData() { this.groupsNames = new ArrayList<String>(0); } @Override public short apiKey() { return 42; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field groupsNames 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field groupsNames element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field groupsNames element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.groupsNames = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field groupsNames 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readShort(); if (length < 0) { throw new RuntimeException("non-nullable field groupsNames element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field groupsNames element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.groupsNames = 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; if (_version >= 2) { _writable.writeUnsignedVarint(groupsNames.size() + 1); for (String groupsNamesElement : groupsNames) { { byte[] _stringBytes = _cache.getSerializedValue(groupsNamesElement); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } } else { _writable.writeInt(groupsNames.size()); for (String groupsNamesElement : groupsNames) { { byte[] _stringBytes = _cache.getSerializedValue(groupsNamesElement); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } } } 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 >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(groupsNames.size() + 1)); } else { _size.addBytes(4); } for (String groupsNamesElement : groupsNames) { byte[] _stringBytes = groupsNamesElement.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'groupsNamesElement' field is too long to be serialized"); } _cache.cacheSerializedValue(groupsNamesElement, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 DeleteGroupsRequestData)) return false; DeleteGroupsRequestData other = (DeleteGroupsRequestData) obj; if (this.groupsNames == null) { if (other.groupsNames != null) return false; } else { if (!this.groupsNames.equals(other.groupsNames)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (groupsNames == null ? 0 : groupsNames.hashCode()); return hashCode; } @Override public DeleteGroupsRequestData duplicate() { DeleteGroupsRequestData _duplicate = new DeleteGroupsRequestData(); ArrayList<String> newGroupsNames = new ArrayList<String>(groupsNames.size()); for (String _element : groupsNames) { newGroupsNames.add(_element); } _duplicate.groupsNames = newGroupsNames; return _duplicate; } @Override public String toString() { return "DeleteGroupsRequestData(" + "groupsNames=" + MessageUtil.deepToString(groupsNames.iterator()) + ")"; } public List<String> groupsNames() { return this.groupsNames; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteGroupsRequestData setGroupsNames(List<String> v) { this.groupsNames = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteGroupsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import static org.apache.kafka.common.message.DeleteGroupsRequestData.*; public class DeleteGroupsRequestDataJsonConverter { public static DeleteGroupsRequestData read(JsonNode _node, short _version) { DeleteGroupsRequestData _object = new DeleteGroupsRequestData(); JsonNode _groupsNamesNode = _node.get("groupsNames"); if (_groupsNamesNode == null) { throw new RuntimeException("DeleteGroupsRequestData: unable to locate field 'groupsNames', which is mandatory in version " + _version); } else { if (!_groupsNamesNode.isArray()) { throw new RuntimeException("DeleteGroupsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<String> _collection = new ArrayList<String>(_groupsNamesNode.size()); _object.groupsNames = _collection; for (JsonNode _element : _groupsNamesNode) { if (!_element.isTextual()) { throw new RuntimeException("DeleteGroupsRequestData element expected a string type, but got " + _node.getNodeType()); } _collection.add(_element.asText()); } } return _object; } public static JsonNode write(DeleteGroupsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _groupsNamesArray = new ArrayNode(JsonNodeFactory.instance); for (String _element : _object.groupsNames) { _groupsNamesArray.add(new TextNode(_element)); } _node.set("groupsNames", _groupsNamesArray); return _node; } public static JsonNode write(DeleteGroupsRequestData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteGroupsResponseData.java
/* * 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.Iterator; 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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class DeleteGroupsResponseData implements ApiMessage { int throttleTimeMs; DeletableGroupResultCollection results; private List<RawTaggedField> _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("results", new ArrayOf(DeletableGroupResult.SCHEMA_0), "The deletion results") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = 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("results", new CompactArrayOf(DeletableGroupResult.SCHEMA_2), "The deletion results"), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeleteGroupsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DeleteGroupsResponseData() { this.throttleTimeMs = 0; this.results = new DeletableGroupResultCollection(0); } @Override public short apiKey() { return 42; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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."); } DeletableGroupResultCollection newCollection = new DeletableGroupResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeletableGroupResult(_readable, _version)); } this.results = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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."); } DeletableGroupResultCollection newCollection = new DeletableGroupResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeletableGroupResult(_readable, _version)); } this.results = 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.writeInt(throttleTimeMs); if (_version >= 2) { _writable.writeUnsignedVarint(results.size() + 1); for (DeletableGroupResult resultsElement : results) { resultsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(results.size()); for (DeletableGroupResult resultsElement : results) { resultsElement.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(4); { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(results.size() + 1)); } else { _size.addBytes(4); } for (DeletableGroupResult resultsElement : results) { resultsElement.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 DeleteGroupsResponseData)) return false; DeleteGroupsResponseData other = (DeleteGroupsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.results == null) { if (other.results != null) return false; } else { if (!this.results.equals(other.results)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (results == null ? 0 : results.hashCode()); return hashCode; } @Override public DeleteGroupsResponseData duplicate() { DeleteGroupsResponseData _duplicate = new DeleteGroupsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; DeletableGroupResultCollection newResults = new DeletableGroupResultCollection(results.size()); for (DeletableGroupResult _element : results) { newResults.add(_element.duplicate()); } _duplicate.results = newResults; return _duplicate; } @Override public String toString() { return "DeleteGroupsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", results=" + MessageUtil.deepToString(results.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public DeletableGroupResultCollection results() { return this.results; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteGroupsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DeleteGroupsResponseData setResults(DeletableGroupResultCollection v) { this.results = v; return this; } public static class DeletableGroupResult implements Message, ImplicitLinkedHashMultiCollection.Element { String groupId; short errorCode; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("group_id", Type.STRING, "The group id"), new Field("error_code", Type.INT16, "The deletion error, or 0 if the deletion succeeded.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("group_id", Type.COMPACT_STRING, "The group id"), new Field("error_code", Type.INT16, "The deletion error, or 0 if the deletion succeeded."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeletableGroupResult(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public DeletableGroupResult() { this.groupId = ""; this.errorCode = (short) 0; this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version > 2) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeletableGroupResult"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field groupId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field groupId had invalid length " + length); } else { this.groupId = _readable.readString(length); } } 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(groupId); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _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 > 2) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeletableGroupResult"); } { byte[] _stringBytes = groupId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'groupId' field is too long to be serialized"); } _cache.cacheSerializedValue(groupId, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof DeletableGroupResult)) return false; DeletableGroupResult other = (DeletableGroupResult) obj; if (this.groupId == null) { if (other.groupId != null) return false; } else { if (!this.groupId.equals(other.groupId)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof DeletableGroupResult)) return false; DeletableGroupResult other = (DeletableGroupResult) obj; if (this.groupId == null) { if (other.groupId != null) return false; } else { if (!this.groupId.equals(other.groupId)) return false; } if (errorCode != other.errorCode) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (groupId == null ? 0 : groupId.hashCode()); return hashCode; } @Override public DeletableGroupResult duplicate() { DeletableGroupResult _duplicate = new DeletableGroupResult(); _duplicate.groupId = groupId; _duplicate.errorCode = errorCode; return _duplicate; } @Override public String toString() { return "DeletableGroupResult(" + "groupId=" + ((groupId == null) ? "null" : "'" + groupId.toString() + "'") + ", errorCode=" + errorCode + ")"; } public String groupId() { return this.groupId; } public short errorCode() { return this.errorCode; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeletableGroupResult setGroupId(String v) { this.groupId = v; return this; } public DeletableGroupResult setErrorCode(short v) { this.errorCode = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class DeletableGroupResultCollection extends ImplicitLinkedHashMultiCollection<DeletableGroupResult> { public DeletableGroupResultCollection() { super(); } public DeletableGroupResultCollection(int expectedNumElements) { super(expectedNumElements); } public DeletableGroupResultCollection(Iterator<DeletableGroupResult> iterator) { super(iterator); } public DeletableGroupResult find(String groupId) { DeletableGroupResult _key = new DeletableGroupResult(); _key.setGroupId(groupId); return find(_key); } public List<DeletableGroupResult> findAll(String groupId) { DeletableGroupResult _key = new DeletableGroupResult(); _key.setGroupId(groupId); return findAll(_key); } public DeletableGroupResultCollection duplicate() { DeletableGroupResultCollection _duplicate = new DeletableGroupResultCollection(size()); for (DeletableGroupResult _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteGroupsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DeleteGroupsResponseData.*; public class DeleteGroupsResponseDataJsonConverter { public static DeleteGroupsResponseData read(JsonNode _node, short _version) { DeleteGroupsResponseData _object = new DeleteGroupsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DeleteGroupsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DeleteGroupsResponseData"); } JsonNode _resultsNode = _node.get("results"); if (_resultsNode == null) { throw new RuntimeException("DeleteGroupsResponseData: unable to locate field 'results', which is mandatory in version " + _version); } else { if (!_resultsNode.isArray()) { throw new RuntimeException("DeleteGroupsResponseData expected a JSON array, but got " + _node.getNodeType()); } DeletableGroupResultCollection _collection = new DeletableGroupResultCollection(_resultsNode.size()); _object.results = _collection; for (JsonNode _element : _resultsNode) { _collection.add(DeletableGroupResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DeleteGroupsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); ArrayNode _resultsArray = new ArrayNode(JsonNodeFactory.instance); for (DeletableGroupResult _element : _object.results) { _resultsArray.add(DeletableGroupResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("results", _resultsArray); return _node; } public static JsonNode write(DeleteGroupsResponseData _object, short _version) { return write(_object, _version, true); } public static class DeletableGroupResultJsonConverter { public static DeletableGroupResult read(JsonNode _node, short _version) { DeletableGroupResult _object = new DeletableGroupResult(); JsonNode _groupIdNode = _node.get("groupId"); if (_groupIdNode == null) { throw new RuntimeException("DeletableGroupResult: unable to locate field 'groupId', which is mandatory in version " + _version); } else { if (!_groupIdNode.isTextual()) { throw new RuntimeException("DeletableGroupResult expected a string type, but got " + _node.getNodeType()); } _object.groupId = _groupIdNode.asText(); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DeletableGroupResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DeletableGroupResult"); } return _object; } public static JsonNode write(DeletableGroupResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("groupId", new TextNode(_object.groupId)); _node.set("errorCode", new ShortNode(_object.errorCode)); return _node; } public static JsonNode write(DeletableGroupResult _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteRecordsRequestData.java
/* * 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 DeleteRecordsRequestData implements ApiMessage { List<DeleteRecordsTopic> topics; int timeoutMs; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topics", new ArrayOf(DeleteRecordsTopic.SCHEMA_0), "Each topic that we want to delete records from."), new Field("timeout_ms", Type.INT32, "How long to wait for the deletion to complete, in milliseconds.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("topics", new CompactArrayOf(DeleteRecordsTopic.SCHEMA_2), "Each topic that we want to delete records from."), new Field("timeout_ms", Type.INT32, "How long to wait for the deletion to complete, in milliseconds."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeleteRecordsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DeleteRecordsRequestData() { this.topics = new ArrayList<DeleteRecordsTopic>(0); this.timeoutMs = 0; } @Override public short apiKey() { return 21; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<DeleteRecordsTopic> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteRecordsTopic(_readable, _version)); } this.topics = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<DeleteRecordsTopic> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteRecordsTopic(_readable, _version)); } this.topics = newCollection; } } } this.timeoutMs = _readable.readInt(); 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; if (_version >= 2) { _writable.writeUnsignedVarint(topics.size() + 1); for (DeleteRecordsTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(topics.size()); for (DeleteRecordsTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } _writable.writeInt(timeoutMs); 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 >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); } else { _size.addBytes(4); } for (DeleteRecordsTopic topicsElement : topics) { topicsElement.addSize(_size, _cache, _version); } } _size.addBytes(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()); } } 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 DeleteRecordsRequestData)) return false; DeleteRecordsRequestData other = (DeleteRecordsRequestData) obj; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } if (timeoutMs != other.timeoutMs) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); hashCode = 31 * hashCode + timeoutMs; return hashCode; } @Override public DeleteRecordsRequestData duplicate() { DeleteRecordsRequestData _duplicate = new DeleteRecordsRequestData(); ArrayList<DeleteRecordsTopic> newTopics = new ArrayList<DeleteRecordsTopic>(topics.size()); for (DeleteRecordsTopic _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; _duplicate.timeoutMs = timeoutMs; return _duplicate; } @Override public String toString() { return "DeleteRecordsRequestData(" + "topics=" + MessageUtil.deepToString(topics.iterator()) + ", timeoutMs=" + timeoutMs + ")"; } public List<DeleteRecordsTopic> topics() { return this.topics; } public int timeoutMs() { return this.timeoutMs; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteRecordsRequestData setTopics(List<DeleteRecordsTopic> v) { this.topics = v; return this; } public DeleteRecordsRequestData setTimeoutMs(int v) { this.timeoutMs = v; return this; } public static class DeleteRecordsTopic implements Message { String name; List<DeleteRecordsPartition> partitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The topic name."), new Field("partitions", new ArrayOf(DeleteRecordsPartition.SCHEMA_0), "Each partition that we want to delete records from.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("partitions", new CompactArrayOf(DeleteRecordsPartition.SCHEMA_2), "Each partition that we want to delete records from."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeleteRecordsTopic(Readable _readable, short _version) { read(_readable, _version); } public DeleteRecordsTopic() { this.name = ""; this.partitions = new ArrayList<DeleteRecordsPartition>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version > 2) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteRecordsTopic"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { if (_version >= 2) { 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<DeleteRecordsPartition> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteRecordsPartition(_readable, _version)); } this.partitions = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); 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<DeleteRecordsPartition> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteRecordsPartition(_readable, _version)); } this.partitions = 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; { byte[] _stringBytes = _cache.getSerializedValue(name); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(partitions.size() + 1); for (DeleteRecordsPartition partitionsElement : partitions) { partitionsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(partitions.size()); for (DeleteRecordsPartition partitionsElement : partitions) { partitionsElement.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; if (_version > 2) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeleteRecordsTopic"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1)); } else { _size.addBytes(4); } for (DeleteRecordsPartition partitionsElement : partitions) { partitionsElement.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 DeleteRecordsTopic)) return false; DeleteRecordsTopic other = (DeleteRecordsTopic) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) 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 + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + (partitions == null ? 0 : partitions.hashCode()); return hashCode; } @Override public DeleteRecordsTopic duplicate() { DeleteRecordsTopic _duplicate = new DeleteRecordsTopic(); _duplicate.name = name; ArrayList<DeleteRecordsPartition> newPartitions = new ArrayList<DeleteRecordsPartition>(partitions.size()); for (DeleteRecordsPartition _element : partitions) { newPartitions.add(_element.duplicate()); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "DeleteRecordsTopic(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String name() { return this.name; } public List<DeleteRecordsPartition> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteRecordsTopic setName(String v) { this.name = v; return this; } public DeleteRecordsTopic setPartitions(List<DeleteRecordsPartition> v) { this.partitions = v; return this; } } public static class DeleteRecordsPartition implements Message { int partitionIndex; long offset; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("offset", Type.INT64, "The deletion offset.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("offset", Type.INT64, "The deletion offset."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeleteRecordsPartition(Readable _readable, short _version) { read(_readable, _version); } public DeleteRecordsPartition() { this.partitionIndex = 0; this.offset = 0L; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version > 2) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteRecordsPartition"); } this.partitionIndex = _readable.readInt(); this.offset = _readable.readLong(); 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.writeInt(partitionIndex); _writable.writeLong(offset); 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 > 2) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeleteRecordsPartition"); } _size.addBytes(4); _size.addBytes(8); 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 DeleteRecordsPartition)) return false; DeleteRecordsPartition other = (DeleteRecordsPartition) obj; if (partitionIndex != other.partitionIndex) return false; if (offset != other.offset) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; hashCode = 31 * hashCode + ((int) (offset >> 32) ^ (int) offset); return hashCode; } @Override public DeleteRecordsPartition duplicate() { DeleteRecordsPartition _duplicate = new DeleteRecordsPartition(); _duplicate.partitionIndex = partitionIndex; _duplicate.offset = offset; return _duplicate; } @Override public String toString() { return "DeleteRecordsPartition(" + "partitionIndex=" + partitionIndex + ", offset=" + offset + ")"; } public int partitionIndex() { return this.partitionIndex; } public long offset() { return this.offset; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteRecordsPartition setPartitionIndex(int v) { this.partitionIndex = v; return this; } public DeleteRecordsPartition setOffset(long v) { this.offset = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteRecordsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DeleteRecordsRequestData.*; public class DeleteRecordsRequestDataJsonConverter { public static DeleteRecordsRequestData read(JsonNode _node, short _version) { DeleteRecordsRequestData _object = new DeleteRecordsRequestData(); JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("DeleteRecordsRequestData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DeleteRecordsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DeleteRecordsTopic> _collection = new ArrayList<DeleteRecordsTopic>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(DeleteRecordsTopicJsonConverter.read(_element, _version)); } } JsonNode _timeoutMsNode = _node.get("timeoutMs"); if (_timeoutMsNode == null) { throw new RuntimeException("DeleteRecordsRequestData: unable to locate field 'timeoutMs', which is mandatory in version " + _version); } else { _object.timeoutMs = MessageUtil.jsonNodeToInt(_timeoutMsNode, "DeleteRecordsRequestData"); } return _object; } public static JsonNode write(DeleteRecordsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (DeleteRecordsTopic _element : _object.topics) { _topicsArray.add(DeleteRecordsTopicJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); _node.set("timeoutMs", new IntNode(_object.timeoutMs)); return _node; } public static JsonNode write(DeleteRecordsRequestData _object, short _version) { return write(_object, _version, true); } public static class DeleteRecordsPartitionJsonConverter { public static DeleteRecordsPartition read(JsonNode _node, short _version) { DeleteRecordsPartition _object = new DeleteRecordsPartition(); JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("DeleteRecordsPartition: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "DeleteRecordsPartition"); } JsonNode _offsetNode = _node.get("offset"); if (_offsetNode == null) { throw new RuntimeException("DeleteRecordsPartition: unable to locate field 'offset', which is mandatory in version " + _version); } else { _object.offset = MessageUtil.jsonNodeToLong(_offsetNode, "DeleteRecordsPartition"); } return _object; } public static JsonNode write(DeleteRecordsPartition _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); _node.set("offset", new LongNode(_object.offset)); return _node; } public static JsonNode write(DeleteRecordsPartition _object, short _version) { return write(_object, _version, true); } } public static class DeleteRecordsTopicJsonConverter { public static DeleteRecordsTopic read(JsonNode _node, short _version) { DeleteRecordsTopic _object = new DeleteRecordsTopic(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("DeleteRecordsTopic: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("DeleteRecordsTopic expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("DeleteRecordsTopic: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("DeleteRecordsTopic expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DeleteRecordsPartition> _collection = new ArrayList<DeleteRecordsPartition>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(DeleteRecordsPartitionJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DeleteRecordsTopic _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (DeleteRecordsPartition _element : _object.partitions) { _partitionsArray.add(DeleteRecordsPartitionJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(DeleteRecordsTopic _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteRecordsResponseData.java
/* * 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.Iterator; 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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class DeleteRecordsResponseData implements ApiMessage { int throttleTimeMs; DeleteRecordsTopicResultCollection topics; private List<RawTaggedField> _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("topics", new ArrayOf(DeleteRecordsTopicResult.SCHEMA_0), "Each topic that we wanted to delete records from.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = 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("topics", new CompactArrayOf(DeleteRecordsTopicResult.SCHEMA_2), "Each topic that we wanted to delete records from."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeleteRecordsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DeleteRecordsResponseData() { this.throttleTimeMs = 0; this.topics = new DeleteRecordsTopicResultCollection(0); } @Override public short apiKey() { return 21; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } DeleteRecordsTopicResultCollection newCollection = new DeleteRecordsTopicResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteRecordsTopicResult(_readable, _version)); } this.topics = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } DeleteRecordsTopicResultCollection newCollection = new DeleteRecordsTopicResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteRecordsTopicResult(_readable, _version)); } this.topics = 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.writeInt(throttleTimeMs); if (_version >= 2) { _writable.writeUnsignedVarint(topics.size() + 1); for (DeleteRecordsTopicResult topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(topics.size()); for (DeleteRecordsTopicResult topicsElement : topics) { topicsElement.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(4); { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); } else { _size.addBytes(4); } for (DeleteRecordsTopicResult topicsElement : topics) { topicsElement.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 DeleteRecordsResponseData)) return false; DeleteRecordsResponseData other = (DeleteRecordsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public DeleteRecordsResponseData duplicate() { DeleteRecordsResponseData _duplicate = new DeleteRecordsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; DeleteRecordsTopicResultCollection newTopics = new DeleteRecordsTopicResultCollection(topics.size()); for (DeleteRecordsTopicResult _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "DeleteRecordsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public DeleteRecordsTopicResultCollection topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteRecordsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DeleteRecordsResponseData setTopics(DeleteRecordsTopicResultCollection v) { this.topics = v; return this; } public static class DeleteRecordsTopicResult implements Message, ImplicitLinkedHashMultiCollection.Element { String name; DeleteRecordsPartitionResultCollection partitions; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The topic name."), new Field("partitions", new ArrayOf(DeleteRecordsPartitionResult.SCHEMA_0), "Each partition that we wanted to delete records from.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("partitions", new CompactArrayOf(DeleteRecordsPartitionResult.SCHEMA_2), "Each partition that we wanted to delete records from."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeleteRecordsTopicResult(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public DeleteRecordsTopicResult() { this.name = ""; this.partitions = new DeleteRecordsPartitionResultCollection(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version > 2) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteRecordsTopicResult"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { if (_version >= 2) { 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."); } DeleteRecordsPartitionResultCollection newCollection = new DeleteRecordsPartitionResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteRecordsPartitionResult(_readable, _version)); } this.partitions = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); 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."); } DeleteRecordsPartitionResultCollection newCollection = new DeleteRecordsPartitionResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteRecordsPartitionResult(_readable, _version)); } this.partitions = 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; { byte[] _stringBytes = _cache.getSerializedValue(name); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(partitions.size() + 1); for (DeleteRecordsPartitionResult partitionsElement : partitions) { partitionsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(partitions.size()); for (DeleteRecordsPartitionResult partitionsElement : partitions) { partitionsElement.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; if (_version > 2) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeleteRecordsTopicResult"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1)); } else { _size.addBytes(4); } for (DeleteRecordsPartitionResult partitionsElement : partitions) { partitionsElement.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 elementKeysAreEqual(Object obj) { if (!(obj instanceof DeleteRecordsTopicResult)) return false; DeleteRecordsTopicResult other = (DeleteRecordsTopicResult) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof DeleteRecordsTopicResult)) return false; DeleteRecordsTopicResult other = (DeleteRecordsTopicResult) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) 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 + (name == null ? 0 : name.hashCode()); return hashCode; } @Override public DeleteRecordsTopicResult duplicate() { DeleteRecordsTopicResult _duplicate = new DeleteRecordsTopicResult(); _duplicate.name = name; DeleteRecordsPartitionResultCollection newPartitions = new DeleteRecordsPartitionResultCollection(partitions.size()); for (DeleteRecordsPartitionResult _element : partitions) { newPartitions.add(_element.duplicate()); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "DeleteRecordsTopicResult(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String name() { return this.name; } public DeleteRecordsPartitionResultCollection partitions() { return this.partitions; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteRecordsTopicResult setName(String v) { this.name = v; return this; } public DeleteRecordsTopicResult setPartitions(DeleteRecordsPartitionResultCollection v) { this.partitions = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class DeleteRecordsPartitionResult implements Message, ImplicitLinkedHashMultiCollection.Element { int partitionIndex; long lowWatermark; short errorCode; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("low_watermark", Type.INT64, "The partition low water mark."), new Field("error_code", Type.INT16, "The deletion error code, or 0 if the deletion succeeded.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("low_watermark", Type.INT64, "The partition low water mark."), new Field("error_code", Type.INT16, "The deletion error code, or 0 if the deletion succeeded."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public DeleteRecordsPartitionResult(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public DeleteRecordsPartitionResult() { this.partitionIndex = 0; this.lowWatermark = 0L; this.errorCode = (short) 0; this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version > 2) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteRecordsPartitionResult"); } this.partitionIndex = _readable.readInt(); this.lowWatermark = _readable.readLong(); 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; _writable.writeInt(partitionIndex); _writable.writeLong(lowWatermark); _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 > 2) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeleteRecordsPartitionResult"); } _size.addBytes(4); _size.addBytes(8); _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof DeleteRecordsPartitionResult)) return false; DeleteRecordsPartitionResult other = (DeleteRecordsPartitionResult) obj; if (partitionIndex != other.partitionIndex) return false; return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof DeleteRecordsPartitionResult)) return false; DeleteRecordsPartitionResult other = (DeleteRecordsPartitionResult) obj; if (partitionIndex != other.partitionIndex) return false; if (lowWatermark != other.lowWatermark) return false; if (errorCode != other.errorCode) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; return hashCode; } @Override public DeleteRecordsPartitionResult duplicate() { DeleteRecordsPartitionResult _duplicate = new DeleteRecordsPartitionResult(); _duplicate.partitionIndex = partitionIndex; _duplicate.lowWatermark = lowWatermark; _duplicate.errorCode = errorCode; return _duplicate; } @Override public String toString() { return "DeleteRecordsPartitionResult(" + "partitionIndex=" + partitionIndex + ", lowWatermark=" + lowWatermark + ", errorCode=" + errorCode + ")"; } public int partitionIndex() { return this.partitionIndex; } public long lowWatermark() { return this.lowWatermark; } public short errorCode() { return this.errorCode; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteRecordsPartitionResult setPartitionIndex(int v) { this.partitionIndex = v; return this; } public DeleteRecordsPartitionResult setLowWatermark(long v) { this.lowWatermark = v; return this; } public DeleteRecordsPartitionResult setErrorCode(short v) { this.errorCode = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class DeleteRecordsPartitionResultCollection extends ImplicitLinkedHashMultiCollection<DeleteRecordsPartitionResult> { public DeleteRecordsPartitionResultCollection() { super(); } public DeleteRecordsPartitionResultCollection(int expectedNumElements) { super(expectedNumElements); } public DeleteRecordsPartitionResultCollection(Iterator<DeleteRecordsPartitionResult> iterator) { super(iterator); } public DeleteRecordsPartitionResult find(int partitionIndex) { DeleteRecordsPartitionResult _key = new DeleteRecordsPartitionResult(); _key.setPartitionIndex(partitionIndex); return find(_key); } public List<DeleteRecordsPartitionResult> findAll(int partitionIndex) { DeleteRecordsPartitionResult _key = new DeleteRecordsPartitionResult(); _key.setPartitionIndex(partitionIndex); return findAll(_key); } public DeleteRecordsPartitionResultCollection duplicate() { DeleteRecordsPartitionResultCollection _duplicate = new DeleteRecordsPartitionResultCollection(size()); for (DeleteRecordsPartitionResult _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } public static class DeleteRecordsTopicResultCollection extends ImplicitLinkedHashMultiCollection<DeleteRecordsTopicResult> { public DeleteRecordsTopicResultCollection() { super(); } public DeleteRecordsTopicResultCollection(int expectedNumElements) { super(expectedNumElements); } public DeleteRecordsTopicResultCollection(Iterator<DeleteRecordsTopicResult> iterator) { super(iterator); } public DeleteRecordsTopicResult find(String name) { DeleteRecordsTopicResult _key = new DeleteRecordsTopicResult(); _key.setName(name); return find(_key); } public List<DeleteRecordsTopicResult> findAll(String name) { DeleteRecordsTopicResult _key = new DeleteRecordsTopicResult(); _key.setName(name); return findAll(_key); } public DeleteRecordsTopicResultCollection duplicate() { DeleteRecordsTopicResultCollection _duplicate = new DeleteRecordsTopicResultCollection(size()); for (DeleteRecordsTopicResult _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteRecordsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DeleteRecordsResponseData.*; public class DeleteRecordsResponseDataJsonConverter { public static DeleteRecordsResponseData read(JsonNode _node, short _version) { DeleteRecordsResponseData _object = new DeleteRecordsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DeleteRecordsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DeleteRecordsResponseData"); } JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("DeleteRecordsResponseData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DeleteRecordsResponseData expected a JSON array, but got " + _node.getNodeType()); } DeleteRecordsTopicResultCollection _collection = new DeleteRecordsTopicResultCollection(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(DeleteRecordsTopicResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DeleteRecordsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (DeleteRecordsTopicResult _element : _object.topics) { _topicsArray.add(DeleteRecordsTopicResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); return _node; } public static JsonNode write(DeleteRecordsResponseData _object, short _version) { return write(_object, _version, true); } public static class DeleteRecordsPartitionResultJsonConverter { public static DeleteRecordsPartitionResult read(JsonNode _node, short _version) { DeleteRecordsPartitionResult _object = new DeleteRecordsPartitionResult(); JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("DeleteRecordsPartitionResult: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "DeleteRecordsPartitionResult"); } JsonNode _lowWatermarkNode = _node.get("lowWatermark"); if (_lowWatermarkNode == null) { throw new RuntimeException("DeleteRecordsPartitionResult: unable to locate field 'lowWatermark', which is mandatory in version " + _version); } else { _object.lowWatermark = MessageUtil.jsonNodeToLong(_lowWatermarkNode, "DeleteRecordsPartitionResult"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DeleteRecordsPartitionResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DeleteRecordsPartitionResult"); } return _object; } public static JsonNode write(DeleteRecordsPartitionResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); _node.set("lowWatermark", new LongNode(_object.lowWatermark)); _node.set("errorCode", new ShortNode(_object.errorCode)); return _node; } public static JsonNode write(DeleteRecordsPartitionResult _object, short _version) { return write(_object, _version, true); } } public static class DeleteRecordsTopicResultJsonConverter { public static DeleteRecordsTopicResult read(JsonNode _node, short _version) { DeleteRecordsTopicResult _object = new DeleteRecordsTopicResult(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("DeleteRecordsTopicResult: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("DeleteRecordsTopicResult expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("DeleteRecordsTopicResult: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("DeleteRecordsTopicResult expected a JSON array, but got " + _node.getNodeType()); } DeleteRecordsPartitionResultCollection _collection = new DeleteRecordsPartitionResultCollection(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(DeleteRecordsPartitionResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DeleteRecordsTopicResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (DeleteRecordsPartitionResult _element : _object.partitions) { _partitionsArray.add(DeleteRecordsPartitionResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(DeleteRecordsTopicResult _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteTopicsRequestData.java
/* * 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.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 DeleteTopicsRequestData implements ApiMessage { List<DeleteTopicState> topics; List<String> topicNames; int timeoutMs; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topic_names", new ArrayOf(Type.STRING), "The names of the topics to delete"), new Field("timeout_ms", Type.INT32, "The length of time in milliseconds to wait for the deletions to complete.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = new Schema( new Field("topic_names", new CompactArrayOf(Type.COMPACT_STRING), "The names of the topics to delete"), new Field("timeout_ms", Type.INT32, "The length of time in milliseconds to wait for the deletions to complete."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_5 = SCHEMA_4; public static final Schema SCHEMA_6 = new Schema( new Field("topics", new CompactArrayOf(DeleteTopicState.SCHEMA_6), "The name or topic ID of the topic"), new Field("timeout_ms", Type.INT32, "The length of time in milliseconds to wait for the deletions to complete."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 6; public DeleteTopicsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DeleteTopicsRequestData() { this.topics = new ArrayList<DeleteTopicState>(0); this.topicNames = new ArrayList<String>(0); this.timeoutMs = 0; } @Override public short apiKey() { return 20; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 6; } @Override public void read(Readable _readable, short _version) { if (_version >= 6) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<DeleteTopicState> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeleteTopicState(_readable, _version)); } this.topics = newCollection; } } else { this.topics = new ArrayList<DeleteTopicState>(0); } if (_version <= 5) { if (_version >= 4) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topicNames 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field topicNames element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topicNames element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.topicNames = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topicNames 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readShort(); if (length < 0) { throw new RuntimeException("non-nullable field topicNames element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topicNames element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.topicNames = newCollection; } } } else { this.topicNames = new ArrayList<String>(0); } this.timeoutMs = _readable.readInt(); this._unknownTaggedFields = null; if (_version >= 4) { 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; if (_version >= 6) { _writable.writeUnsignedVarint(topics.size() + 1); for (DeleteTopicState topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } else { if (!this.topics.isEmpty()) { throw new UnsupportedVersionException("Attempted to write a non-default topics at version " + _version); } } if (_version <= 5) { if (_version >= 4) { _writable.writeUnsignedVarint(topicNames.size() + 1); for (String topicNamesElement : topicNames) { { byte[] _stringBytes = _cache.getSerializedValue(topicNamesElement); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } } else { _writable.writeInt(topicNames.size()); for (String topicNamesElement : topicNames) { { byte[] _stringBytes = _cache.getSerializedValue(topicNamesElement); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } } } } _writable.writeInt(timeoutMs); RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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 >= 6) { { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); for (DeleteTopicState topicsElement : topics) { topicsElement.addSize(_size, _cache, _version); } } } if (_version <= 5) { { if (_version >= 4) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topicNames.size() + 1)); } else { _size.addBytes(4); } for (String topicNamesElement : topicNames) { byte[] _stringBytes = topicNamesElement.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'topicNamesElement' field is too long to be serialized"); } _cache.cacheSerializedValue(topicNamesElement, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } } } _size.addBytes(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()); } } if (_version >= 4) { _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 DeleteTopicsRequestData)) return false; DeleteTopicsRequestData other = (DeleteTopicsRequestData) obj; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } if (this.topicNames == null) { if (other.topicNames != null) return false; } else { if (!this.topicNames.equals(other.topicNames)) return false; } if (timeoutMs != other.timeoutMs) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); hashCode = 31 * hashCode + (topicNames == null ? 0 : topicNames.hashCode()); hashCode = 31 * hashCode + timeoutMs; return hashCode; } @Override public DeleteTopicsRequestData duplicate() { DeleteTopicsRequestData _duplicate = new DeleteTopicsRequestData(); ArrayList<DeleteTopicState> newTopics = new ArrayList<DeleteTopicState>(topics.size()); for (DeleteTopicState _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; ArrayList<String> newTopicNames = new ArrayList<String>(topicNames.size()); for (String _element : topicNames) { newTopicNames.add(_element); } _duplicate.topicNames = newTopicNames; _duplicate.timeoutMs = timeoutMs; return _duplicate; } @Override public String toString() { return "DeleteTopicsRequestData(" + "topics=" + MessageUtil.deepToString(topics.iterator()) + ", topicNames=" + MessageUtil.deepToString(topicNames.iterator()) + ", timeoutMs=" + timeoutMs + ")"; } public List<DeleteTopicState> topics() { return this.topics; } public List<String> topicNames() { return this.topicNames; } public int timeoutMs() { return this.timeoutMs; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteTopicsRequestData setTopics(List<DeleteTopicState> v) { this.topics = v; return this; } public DeleteTopicsRequestData setTopicNames(List<String> v) { this.topicNames = v; return this; } public DeleteTopicsRequestData setTimeoutMs(int v) { this.timeoutMs = v; return this; } public static class DeleteTopicState implements Message { String name; Uuid topicId; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_6 = new Schema( new Field("name", Type.COMPACT_NULLABLE_STRING, "The topic name"), new Field("topic_id", Type.UUID, "The unique topic ID"), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { null, null, null, null, null, null, SCHEMA_6 }; public static final short LOWEST_SUPPORTED_VERSION = 6; public static final short HIGHEST_SUPPORTED_VERSION = 6; public DeleteTopicState(Readable _readable, short _version) { read(_readable, _version); } public DeleteTopicState() { this.name = null; this.topicId = Uuid.ZERO_UUID; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 6; } @Override public void read(Readable _readable, short _version) { if (_version > 6) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteTopicState"); } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.name = null; } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } this.topicId = _readable.readUuid(); 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) { if (_version < 6) { throw new UnsupportedVersionException("Can't write version " + _version + " of DeleteTopicState"); } int _numTaggedFields = 0; if (name == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(name); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeUuid(topicId); 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 > 6) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeleteTopicState"); } if (name == null) { _size.addBytes(1); } else { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _size.addBytes(16); 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 DeleteTopicState)) return false; DeleteTopicState other = (DeleteTopicState) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (!this.topicId.equals(other.topicId)) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + topicId.hashCode(); return hashCode; } @Override public DeleteTopicState duplicate() { DeleteTopicState _duplicate = new DeleteTopicState(); if (name == null) { _duplicate.name = null; } else { _duplicate.name = name; } _duplicate.topicId = topicId; return _duplicate; } @Override public String toString() { return "DeleteTopicState(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", topicId=" + topicId.toString() + ")"; } public String name() { return this.name; } public Uuid topicId() { return this.topicId; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteTopicState setName(String v) { this.name = v; return this; } public DeleteTopicState setTopicId(Uuid v) { this.topicId = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteTopicsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DeleteTopicsRequestData.*; public class DeleteTopicsRequestDataJsonConverter { public static DeleteTopicsRequestData read(JsonNode _node, short _version) { DeleteTopicsRequestData _object = new DeleteTopicsRequestData(); JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { if (_version >= 6) { throw new RuntimeException("DeleteTopicsRequestData: unable to locate field 'topics', which is mandatory in version " + _version); } else { _object.topics = new ArrayList<DeleteTopicState>(0); } } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DeleteTopicsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DeleteTopicState> _collection = new ArrayList<DeleteTopicState>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(DeleteTopicStateJsonConverter.read(_element, _version)); } } JsonNode _topicNamesNode = _node.get("topicNames"); if (_topicNamesNode == null) { if (_version <= 5) { throw new RuntimeException("DeleteTopicsRequestData: unable to locate field 'topicNames', which is mandatory in version " + _version); } else { _object.topicNames = new ArrayList<String>(0); } } else { if (!_topicNamesNode.isArray()) { throw new RuntimeException("DeleteTopicsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<String> _collection = new ArrayList<String>(_topicNamesNode.size()); _object.topicNames = _collection; for (JsonNode _element : _topicNamesNode) { if (!_element.isTextual()) { throw new RuntimeException("DeleteTopicsRequestData element expected a string type, but got " + _node.getNodeType()); } _collection.add(_element.asText()); } } JsonNode _timeoutMsNode = _node.get("timeoutMs"); if (_timeoutMsNode == null) { throw new RuntimeException("DeleteTopicsRequestData: unable to locate field 'timeoutMs', which is mandatory in version " + _version); } else { _object.timeoutMs = MessageUtil.jsonNodeToInt(_timeoutMsNode, "DeleteTopicsRequestData"); } return _object; } public static JsonNode write(DeleteTopicsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_version >= 6) { ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (DeleteTopicState _element : _object.topics) { _topicsArray.add(DeleteTopicStateJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); } else { if (!_object.topics.isEmpty()) { throw new UnsupportedVersionException("Attempted to write a non-default topics at version " + _version); } } if (_version <= 5) { ArrayNode _topicNamesArray = new ArrayNode(JsonNodeFactory.instance); for (String _element : _object.topicNames) { _topicNamesArray.add(new TextNode(_element)); } _node.set("topicNames", _topicNamesArray); } _node.set("timeoutMs", new IntNode(_object.timeoutMs)); return _node; } public static JsonNode write(DeleteTopicsRequestData _object, short _version) { return write(_object, _version, true); } public static class DeleteTopicStateJsonConverter { public static DeleteTopicState read(JsonNode _node, short _version) { DeleteTopicState _object = new DeleteTopicState(); if (_version < 6) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeleteTopicState"); } JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("DeleteTopicState: unable to locate field 'name', which is mandatory in version " + _version); } else { if (_nameNode.isNull()) { _object.name = null; } else { if (!_nameNode.isTextual()) { throw new RuntimeException("DeleteTopicState expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } } JsonNode _topicIdNode = _node.get("topicId"); if (_topicIdNode == null) { throw new RuntimeException("DeleteTopicState: unable to locate field 'topicId', which is mandatory in version " + _version); } else { if (!_topicIdNode.isTextual()) { throw new RuntimeException("DeleteTopicState expected a JSON string type, but got " + _node.getNodeType()); } _object.topicId = Uuid.fromString(_topicIdNode.asText()); } return _object; } public static JsonNode write(DeleteTopicState _object, short _version, boolean _serializeRecords) { if (_version < 6) { throw new UnsupportedVersionException("Can't write version " + _version + " of DeleteTopicState"); } ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_object.name == null) { _node.set("name", NullNode.instance); } else { _node.set("name", new TextNode(_object.name)); } _node.set("topicId", new TextNode(_object.topicId.toString())); return _node; } public static JsonNode write(DeleteTopicState _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteTopicsResponseData.java
/* * 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.Iterator; 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.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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class DeleteTopicsResponseData implements ApiMessage { int throttleTimeMs; DeletableTopicResultCollection responses; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("responses", new ArrayOf(DeletableTopicResult.SCHEMA_0), "The results for each topic we tried to delete.") ); public static final Schema SCHEMA_1 = 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("responses", new ArrayOf(DeletableTopicResult.SCHEMA_0), "The results for each topic we tried to delete.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = 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("responses", new CompactArrayOf(DeletableTopicResult.SCHEMA_4), "The results for each topic we tried to delete."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_5 = 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("responses", new CompactArrayOf(DeletableTopicResult.SCHEMA_5), "The results for each topic we tried to delete."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_6 = 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("responses", new CompactArrayOf(DeletableTopicResult.SCHEMA_6), "The results for each topic we tried to delete."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 6; public DeleteTopicsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DeleteTopicsResponseData() { this.throttleTimeMs = 0; this.responses = new DeletableTopicResultCollection(0); } @Override public short apiKey() { return 20; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 6; } @Override public void read(Readable _readable, short _version) { if (_version >= 1) { this.throttleTimeMs = _readable.readInt(); } else { this.throttleTimeMs = 0; } { if (_version >= 4) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field responses 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."); } DeletableTopicResultCollection newCollection = new DeletableTopicResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeletableTopicResult(_readable, _version)); } this.responses = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field responses 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."); } DeletableTopicResultCollection newCollection = new DeletableTopicResultCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DeletableTopicResult(_readable, _version)); } this.responses = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 4) { 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; if (_version >= 1) { _writable.writeInt(throttleTimeMs); } if (_version >= 4) { _writable.writeUnsignedVarint(responses.size() + 1); for (DeletableTopicResult responsesElement : responses) { responsesElement.write(_writable, _cache, _version); } } else { _writable.writeInt(responses.size()); for (DeletableTopicResult responsesElement : responses) { responsesElement.write(_writable, _cache, _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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 >= 1) { _size.addBytes(4); } { if (_version >= 4) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(responses.size() + 1)); } else { _size.addBytes(4); } for (DeletableTopicResult responsesElement : responses) { responsesElement.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 >= 4) { _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 DeleteTopicsResponseData)) return false; DeleteTopicsResponseData other = (DeleteTopicsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.responses == null) { if (other.responses != null) return false; } else { if (!this.responses.equals(other.responses)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (responses == null ? 0 : responses.hashCode()); return hashCode; } @Override public DeleteTopicsResponseData duplicate() { DeleteTopicsResponseData _duplicate = new DeleteTopicsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; DeletableTopicResultCollection newResponses = new DeletableTopicResultCollection(responses.size()); for (DeletableTopicResult _element : responses) { newResponses.add(_element.duplicate()); } _duplicate.responses = newResponses; return _duplicate; } @Override public String toString() { return "DeleteTopicsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", responses=" + MessageUtil.deepToString(responses.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public DeletableTopicResultCollection responses() { return this.responses; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeleteTopicsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DeleteTopicsResponseData setResponses(DeletableTopicResultCollection v) { this.responses = v; return this; } public static class DeletableTopicResult implements Message, ImplicitLinkedHashMultiCollection.Element { String name; Uuid topicId; short errorCode; String errorMessage; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The topic name"), new Field("error_code", Type.INT16, "The deletion error, or 0 if the deletion succeeded.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name"), new Field("error_code", Type.INT16, "The deletion error, or 0 if the deletion succeeded."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_5 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name"), new Field("error_code", Type.INT16, "The deletion error, or 0 if the deletion succeeded."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The error message, or null if there was no error."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_6 = new Schema( new Field("name", Type.COMPACT_NULLABLE_STRING, "The topic name"), new Field("topic_id", Type.UUID, "the unique topic ID"), new Field("error_code", Type.INT16, "The deletion error, or 0 if the deletion succeeded."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The error message, or null if there was no error."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5, SCHEMA_6 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 6; public DeletableTopicResult(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public DeletableTopicResult() { this.name = ""; this.topicId = Uuid.ZERO_UUID; this.errorCode = (short) 0; this.errorMessage = null; this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 6; } @Override public void read(Readable _readable, short _version) { if (_version > 6) { throw new UnsupportedVersionException("Can't read version " + _version + " of DeletableTopicResult"); } { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { if (_version >= 6) { this.name = null; } else { throw new RuntimeException("non-nullable field name was serialized as null"); } } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } if (_version >= 6) { this.topicId = _readable.readUuid(); } else { this.topicId = Uuid.ZERO_UUID; } this.errorCode = _readable.readShort(); if (_version >= 5) { 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); } } else { this.errorMessage = null; } this._unknownTaggedFields = null; if (_version >= 4) { 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; if (name == null) { if (_version >= 6) { _writable.writeUnsignedVarint(0); } else { throw new NullPointerException(); } } else { byte[] _stringBytes = _cache.getSerializedValue(name); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 6) { _writable.writeUuid(topicId); } _writable.writeShort(errorCode); if (_version >= 5) { if (errorMessage == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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 > 6) { throw new UnsupportedVersionException("Can't size version " + _version + " of DeletableTopicResult"); } if (name == null) { if (_version >= 4) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 6) { _size.addBytes(16); } _size.addBytes(2); if (_version >= 5) { 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 (_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 >= 4) { _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof DeletableTopicResult)) return false; DeletableTopicResult other = (DeletableTopicResult) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof DeletableTopicResult)) return false; DeletableTopicResult other = (DeletableTopicResult) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (!this.topicId.equals(other.topicId)) 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; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); return hashCode; } @Override public DeletableTopicResult duplicate() { DeletableTopicResult _duplicate = new DeletableTopicResult(); if (name == null) { _duplicate.name = null; } else { _duplicate.name = name; } _duplicate.topicId = topicId; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } return _duplicate; } @Override public String toString() { return "DeletableTopicResult(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", topicId=" + topicId.toString() + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ")"; } public String name() { return this.name; } public Uuid topicId() { return this.topicId; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DeletableTopicResult setName(String v) { this.name = v; return this; } public DeletableTopicResult setTopicId(Uuid v) { this.topicId = v; return this; } public DeletableTopicResult setErrorCode(short v) { this.errorCode = v; return this; } public DeletableTopicResult setErrorMessage(String v) { this.errorMessage = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class DeletableTopicResultCollection extends ImplicitLinkedHashMultiCollection<DeletableTopicResult> { public DeletableTopicResultCollection() { super(); } public DeletableTopicResultCollection(int expectedNumElements) { super(expectedNumElements); } public DeletableTopicResultCollection(Iterator<DeletableTopicResult> iterator) { super(iterator); } public DeletableTopicResult find(String name) { DeletableTopicResult _key = new DeletableTopicResult(); _key.setName(name); return find(_key); } public List<DeletableTopicResult> findAll(String name) { DeletableTopicResult _key = new DeletableTopicResult(); _key.setName(name); return findAll(_key); } public DeletableTopicResultCollection duplicate() { DeletableTopicResultCollection _duplicate = new DeletableTopicResultCollection(size()); for (DeletableTopicResult _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DeleteTopicsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DeleteTopicsResponseData.*; public class DeleteTopicsResponseDataJsonConverter { public static DeleteTopicsResponseData read(JsonNode _node, short _version) { DeleteTopicsResponseData _object = new DeleteTopicsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { if (_version >= 1) { throw new RuntimeException("DeleteTopicsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = 0; } } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DeleteTopicsResponseData"); } JsonNode _responsesNode = _node.get("responses"); if (_responsesNode == null) { throw new RuntimeException("DeleteTopicsResponseData: unable to locate field 'responses', which is mandatory in version " + _version); } else { if (!_responsesNode.isArray()) { throw new RuntimeException("DeleteTopicsResponseData expected a JSON array, but got " + _node.getNodeType()); } DeletableTopicResultCollection _collection = new DeletableTopicResultCollection(_responsesNode.size()); _object.responses = _collection; for (JsonNode _element : _responsesNode) { _collection.add(DeletableTopicResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DeleteTopicsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_version >= 1) { _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); } ArrayNode _responsesArray = new ArrayNode(JsonNodeFactory.instance); for (DeletableTopicResult _element : _object.responses) { _responsesArray.add(DeletableTopicResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("responses", _responsesArray); return _node; } public static JsonNode write(DeleteTopicsResponseData _object, short _version) { return write(_object, _version, true); } public static class DeletableTopicResultJsonConverter { public static DeletableTopicResult read(JsonNode _node, short _version) { DeletableTopicResult _object = new DeletableTopicResult(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("DeletableTopicResult: unable to locate field 'name', which is mandatory in version " + _version); } else { if (_nameNode.isNull()) { _object.name = null; } else { if (!_nameNode.isTextual()) { throw new RuntimeException("DeletableTopicResult expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } } JsonNode _topicIdNode = _node.get("topicId"); if (_topicIdNode == null) { if (_version >= 6) { throw new RuntimeException("DeletableTopicResult: unable to locate field 'topicId', which is mandatory in version " + _version); } else { _object.topicId = Uuid.ZERO_UUID; } } else { if (!_topicIdNode.isTextual()) { throw new RuntimeException("DeletableTopicResult expected a JSON string type, but got " + _node.getNodeType()); } _object.topicId = Uuid.fromString(_topicIdNode.asText()); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DeletableTopicResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DeletableTopicResult"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { if (_version >= 5) { throw new RuntimeException("DeletableTopicResult: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { _object.errorMessage = null; } } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DeletableTopicResult expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } return _object; } public static JsonNode write(DeletableTopicResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_object.name == null) { _node.set("name", NullNode.instance); } else { _node.set("name", new TextNode(_object.name)); } if (_version >= 6) { _node.set("topicId", new TextNode(_object.topicId.toString())); } _node.set("errorCode", new ShortNode(_object.errorCode)); if (_version >= 5) { if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } } return _node; } public static JsonNode write(DeletableTopicResult _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeAclsRequestData.java
/* * 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.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.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 DescribeAclsRequestData implements ApiMessage { byte resourceTypeFilter; String resourceNameFilter; byte patternTypeFilter; String principalFilter; String hostFilter; byte operation; byte permissionType; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("resource_type_filter", Type.INT8, "The resource type."), new Field("resource_name_filter", Type.NULLABLE_STRING, "The resource name, or null to match any resource name."), new Field("principal_filter", Type.NULLABLE_STRING, "The principal to match, or null to match any principal."), new Field("host_filter", Type.NULLABLE_STRING, "The host to match, or null to match any host."), new Field("operation", Type.INT8, "The operation to match."), new Field("permission_type", Type.INT8, "The permission type to match.") ); public static final Schema SCHEMA_1 = new Schema( new Field("resource_type_filter", Type.INT8, "The resource type."), new Field("resource_name_filter", Type.NULLABLE_STRING, "The resource name, or null to match any resource name."), new Field("pattern_type_filter", Type.INT8, "The resource pattern to match."), new Field("principal_filter", Type.NULLABLE_STRING, "The principal to match, or null to match any principal."), new Field("host_filter", Type.NULLABLE_STRING, "The host to match, or null to match any host."), new Field("operation", Type.INT8, "The operation to match."), new Field("permission_type", Type.INT8, "The permission type to match.") ); public static final Schema SCHEMA_2 = new Schema( new Field("resource_type_filter", Type.INT8, "The resource type."), new Field("resource_name_filter", Type.COMPACT_NULLABLE_STRING, "The resource name, or null to match any resource name."), new Field("pattern_type_filter", Type.INT8, "The resource pattern to match."), new Field("principal_filter", Type.COMPACT_NULLABLE_STRING, "The principal to match, or null to match any principal."), new Field("host_filter", Type.COMPACT_NULLABLE_STRING, "The host to match, or null to match any host."), new Field("operation", Type.INT8, "The operation to match."), new Field("permission_type", Type.INT8, "The permission type to match."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DescribeAclsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeAclsRequestData() { this.resourceTypeFilter = (byte) 0; this.resourceNameFilter = ""; this.patternTypeFilter = (byte) 3; this.principalFilter = ""; this.hostFilter = ""; this.operation = (byte) 0; this.permissionType = (byte) 0; } @Override public short apiKey() { return 29; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { this.resourceTypeFilter = _readable.readByte(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.resourceNameFilter = null; } else if (length > 0x7fff) { throw new RuntimeException("string field resourceNameFilter had invalid length " + length); } else { this.resourceNameFilter = _readable.readString(length); } } if (_version >= 1) { this.patternTypeFilter = _readable.readByte(); } else { this.patternTypeFilter = (byte) 3; } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.principalFilter = null; } else if (length > 0x7fff) { throw new RuntimeException("string field principalFilter had invalid length " + length); } else { this.principalFilter = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.hostFilter = null; } else if (length > 0x7fff) { throw new RuntimeException("string field hostFilter had invalid length " + length); } else { this.hostFilter = _readable.readString(length); } } this.operation = _readable.readByte(); this.permissionType = _readable.readByte(); 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.writeByte(resourceTypeFilter); if (resourceNameFilter == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(resourceNameFilter); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 1) { _writable.writeByte(patternTypeFilter); } else { if (this.patternTypeFilter != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default patternTypeFilter at version " + _version); } } if (principalFilter == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(principalFilter); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (hostFilter == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(hostFilter); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(operation); _writable.writeByte(permissionType); 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(1); if (resourceNameFilter == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = resourceNameFilter.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'resourceNameFilter' field is too long to be serialized"); } _cache.cacheSerializedValue(resourceNameFilter, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 1) { _size.addBytes(1); } if (principalFilter == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = principalFilter.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalFilter' field is too long to be serialized"); } _cache.cacheSerializedValue(principalFilter, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (hostFilter == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = hostFilter.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'hostFilter' field is too long to be serialized"); } _cache.cacheSerializedValue(hostFilter, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); _size.addBytes(1); 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 DescribeAclsRequestData)) return false; DescribeAclsRequestData other = (DescribeAclsRequestData) obj; if (resourceTypeFilter != other.resourceTypeFilter) return false; if (this.resourceNameFilter == null) { if (other.resourceNameFilter != null) return false; } else { if (!this.resourceNameFilter.equals(other.resourceNameFilter)) return false; } if (patternTypeFilter != other.patternTypeFilter) return false; if (this.principalFilter == null) { if (other.principalFilter != null) return false; } else { if (!this.principalFilter.equals(other.principalFilter)) return false; } if (this.hostFilter == null) { if (other.hostFilter != null) return false; } else { if (!this.hostFilter.equals(other.hostFilter)) return false; } if (operation != other.operation) return false; if (permissionType != other.permissionType) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + resourceTypeFilter; hashCode = 31 * hashCode + (resourceNameFilter == null ? 0 : resourceNameFilter.hashCode()); hashCode = 31 * hashCode + patternTypeFilter; hashCode = 31 * hashCode + (principalFilter == null ? 0 : principalFilter.hashCode()); hashCode = 31 * hashCode + (hostFilter == null ? 0 : hostFilter.hashCode()); hashCode = 31 * hashCode + operation; hashCode = 31 * hashCode + permissionType; return hashCode; } @Override public DescribeAclsRequestData duplicate() { DescribeAclsRequestData _duplicate = new DescribeAclsRequestData(); _duplicate.resourceTypeFilter = resourceTypeFilter; if (resourceNameFilter == null) { _duplicate.resourceNameFilter = null; } else { _duplicate.resourceNameFilter = resourceNameFilter; } _duplicate.patternTypeFilter = patternTypeFilter; if (principalFilter == null) { _duplicate.principalFilter = null; } else { _duplicate.principalFilter = principalFilter; } if (hostFilter == null) { _duplicate.hostFilter = null; } else { _duplicate.hostFilter = hostFilter; } _duplicate.operation = operation; _duplicate.permissionType = permissionType; return _duplicate; } @Override public String toString() { return "DescribeAclsRequestData(" + "resourceTypeFilter=" + resourceTypeFilter + ", resourceNameFilter=" + ((resourceNameFilter == null) ? "null" : "'" + resourceNameFilter.toString() + "'") + ", patternTypeFilter=" + patternTypeFilter + ", principalFilter=" + ((principalFilter == null) ? "null" : "'" + principalFilter.toString() + "'") + ", hostFilter=" + ((hostFilter == null) ? "null" : "'" + hostFilter.toString() + "'") + ", operation=" + operation + ", permissionType=" + permissionType + ")"; } public byte resourceTypeFilter() { return this.resourceTypeFilter; } public String resourceNameFilter() { return this.resourceNameFilter; } public byte patternTypeFilter() { return this.patternTypeFilter; } public String principalFilter() { return this.principalFilter; } public String hostFilter() { return this.hostFilter; } public byte operation() { return this.operation; } public byte permissionType() { return this.permissionType; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeAclsRequestData setResourceTypeFilter(byte v) { this.resourceTypeFilter = v; return this; } public DescribeAclsRequestData setResourceNameFilter(String v) { this.resourceNameFilter = v; return this; } public DescribeAclsRequestData setPatternTypeFilter(byte v) { this.patternTypeFilter = v; return this; } public DescribeAclsRequestData setPrincipalFilter(String v) { this.principalFilter = v; return this; } public DescribeAclsRequestData setHostFilter(String v) { this.hostFilter = v; return this; } public DescribeAclsRequestData setOperation(byte v) { this.operation = v; return this; } public DescribeAclsRequestData setPermissionType(byte v) { this.permissionType = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeAclsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeAclsRequestData.*; public class DescribeAclsRequestDataJsonConverter { public static DescribeAclsRequestData read(JsonNode _node, short _version) { DescribeAclsRequestData _object = new DescribeAclsRequestData(); JsonNode _resourceTypeFilterNode = _node.get("resourceTypeFilter"); if (_resourceTypeFilterNode == null) { throw new RuntimeException("DescribeAclsRequestData: unable to locate field 'resourceTypeFilter', which is mandatory in version " + _version); } else { _object.resourceTypeFilter = MessageUtil.jsonNodeToByte(_resourceTypeFilterNode, "DescribeAclsRequestData"); } JsonNode _resourceNameFilterNode = _node.get("resourceNameFilter"); if (_resourceNameFilterNode == null) { throw new RuntimeException("DescribeAclsRequestData: unable to locate field 'resourceNameFilter', which is mandatory in version " + _version); } else { if (_resourceNameFilterNode.isNull()) { _object.resourceNameFilter = null; } else { if (!_resourceNameFilterNode.isTextual()) { throw new RuntimeException("DescribeAclsRequestData expected a string type, but got " + _node.getNodeType()); } _object.resourceNameFilter = _resourceNameFilterNode.asText(); } } JsonNode _patternTypeFilterNode = _node.get("patternTypeFilter"); if (_patternTypeFilterNode == null) { if (_version >= 1) { throw new RuntimeException("DescribeAclsRequestData: unable to locate field 'patternTypeFilter', which is mandatory in version " + _version); } else { _object.patternTypeFilter = (byte) 3; } } else { _object.patternTypeFilter = MessageUtil.jsonNodeToByte(_patternTypeFilterNode, "DescribeAclsRequestData"); } JsonNode _principalFilterNode = _node.get("principalFilter"); if (_principalFilterNode == null) { throw new RuntimeException("DescribeAclsRequestData: unable to locate field 'principalFilter', which is mandatory in version " + _version); } else { if (_principalFilterNode.isNull()) { _object.principalFilter = null; } else { if (!_principalFilterNode.isTextual()) { throw new RuntimeException("DescribeAclsRequestData expected a string type, but got " + _node.getNodeType()); } _object.principalFilter = _principalFilterNode.asText(); } } JsonNode _hostFilterNode = _node.get("hostFilter"); if (_hostFilterNode == null) { throw new RuntimeException("DescribeAclsRequestData: unable to locate field 'hostFilter', which is mandatory in version " + _version); } else { if (_hostFilterNode.isNull()) { _object.hostFilter = null; } else { if (!_hostFilterNode.isTextual()) { throw new RuntimeException("DescribeAclsRequestData expected a string type, but got " + _node.getNodeType()); } _object.hostFilter = _hostFilterNode.asText(); } } JsonNode _operationNode = _node.get("operation"); if (_operationNode == null) { throw new RuntimeException("DescribeAclsRequestData: unable to locate field 'operation', which is mandatory in version " + _version); } else { _object.operation = MessageUtil.jsonNodeToByte(_operationNode, "DescribeAclsRequestData"); } JsonNode _permissionTypeNode = _node.get("permissionType"); if (_permissionTypeNode == null) { throw new RuntimeException("DescribeAclsRequestData: unable to locate field 'permissionType', which is mandatory in version " + _version); } else { _object.permissionType = MessageUtil.jsonNodeToByte(_permissionTypeNode, "DescribeAclsRequestData"); } return _object; } public static JsonNode write(DescribeAclsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("resourceTypeFilter", new ShortNode(_object.resourceTypeFilter)); if (_object.resourceNameFilter == null) { _node.set("resourceNameFilter", NullNode.instance); } else { _node.set("resourceNameFilter", new TextNode(_object.resourceNameFilter)); } if (_version >= 1) { _node.set("patternTypeFilter", new ShortNode(_object.patternTypeFilter)); } else { if (_object.patternTypeFilter != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default patternTypeFilter at version " + _version); } } if (_object.principalFilter == null) { _node.set("principalFilter", NullNode.instance); } else { _node.set("principalFilter", new TextNode(_object.principalFilter)); } if (_object.hostFilter == null) { _node.set("hostFilter", NullNode.instance); } else { _node.set("hostFilter", new TextNode(_object.hostFilter)); } _node.set("operation", new ShortNode(_object.operation)); _node.set("permissionType", new ShortNode(_object.permissionType)); return _node; } public static JsonNode write(DescribeAclsRequestData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeAclsResponseData.java
/* * 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 DescribeAclsResponseData implements ApiMessage { int throttleTimeMs; short errorCode; String errorMessage; List<DescribeAclsResource> resources; private List<RawTaggedField> _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 error code, or 0 if there was no error."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or null if there was no error."), new Field("resources", new ArrayOf(DescribeAclsResource.SCHEMA_0), "Each Resource that is referenced in an ACL.") ); public static final Schema SCHEMA_1 = 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 error code, or 0 if there was no error."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or null if there was no error."), new Field("resources", new ArrayOf(DescribeAclsResource.SCHEMA_1), "Each Resource that is referenced in an ACL.") ); public static final Schema SCHEMA_2 = 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 error code, or 0 if there was no error."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The error message, or null if there was no error."), new Field("resources", new CompactArrayOf(DescribeAclsResource.SCHEMA_2), "Each Resource that is referenced in an ACL."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DescribeAclsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeAclsResponseData() { this.throttleTimeMs = 0; this.errorCode = (short) 0; this.errorMessage = ""; this.resources = new ArrayList<DescribeAclsResource>(0); } @Override public short apiKey() { return 29; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); this.errorCode = _readable.readShort(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field resources 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<DescribeAclsResource> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeAclsResource(_readable, _version)); } this.resources = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field resources 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<DescribeAclsResource> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeAclsResource(_readable, _version)); } this.resources = 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.writeInt(throttleTimeMs); _writable.writeShort(errorCode); if (errorMessage == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(resources.size() + 1); for (DescribeAclsResource resourcesElement : resources) { resourcesElement.write(_writable, _cache, _version); } } else { _writable.writeInt(resources.size()); for (DescribeAclsResource resourcesElement : resources) { resourcesElement.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(4); _size.addBytes(2); if (errorMessage == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(resources.size() + 1)); } else { _size.addBytes(4); } for (DescribeAclsResource resourcesElement : resources) { resourcesElement.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 DescribeAclsResponseData)) return false; DescribeAclsResponseData other = (DescribeAclsResponseData) 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.resources == null) { if (other.resources != null) return false; } else { if (!this.resources.equals(other.resources)) 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 + (resources == null ? 0 : resources.hashCode()); return hashCode; } @Override public DescribeAclsResponseData duplicate() { DescribeAclsResponseData _duplicate = new DescribeAclsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } ArrayList<DescribeAclsResource> newResources = new ArrayList<DescribeAclsResource>(resources.size()); for (DescribeAclsResource _element : resources) { newResources.add(_element.duplicate()); } _duplicate.resources = newResources; return _duplicate; } @Override public String toString() { return "DescribeAclsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", resources=" + MessageUtil.deepToString(resources.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public List<DescribeAclsResource> resources() { return this.resources; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeAclsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeAclsResponseData setErrorCode(short v) { this.errorCode = v; return this; } public DescribeAclsResponseData setErrorMessage(String v) { this.errorMessage = v; return this; } public DescribeAclsResponseData setResources(List<DescribeAclsResource> v) { this.resources = v; return this; } public static class DescribeAclsResource implements Message { byte resourceType; String resourceName; byte patternType; List<AclDescription> acls; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.STRING, "The resource name."), new Field("acls", new ArrayOf(AclDescription.SCHEMA_0), "The ACLs.") ); public static final Schema SCHEMA_1 = new Schema( new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.STRING, "The resource name."), new Field("pattern_type", Type.INT8, "The resource pattern type."), new Field("acls", new ArrayOf(AclDescription.SCHEMA_0), "The ACLs.") ); public static final Schema SCHEMA_2 = new Schema( new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.COMPACT_STRING, "The resource name."), new Field("pattern_type", Type.INT8, "The resource pattern type."), new Field("acls", new CompactArrayOf(AclDescription.SCHEMA_2), "The ACLs."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DescribeAclsResource(Readable _readable, short _version) { read(_readable, _version); } public DescribeAclsResource() { this.resourceType = (byte) 0; this.resourceName = ""; this.patternType = (byte) 3; this.acls = new ArrayList<AclDescription>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribeAclsResource"); } this.resourceType = _readable.readByte(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field resourceName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field resourceName had invalid length " + length); } else { this.resourceName = _readable.readString(length); } } if (_version >= 1) { this.patternType = _readable.readByte(); } else { this.patternType = (byte) 3; } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field acls 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<AclDescription> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new AclDescription(_readable, _version)); } this.acls = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field acls 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<AclDescription> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new AclDescription(_readable, _version)); } this.acls = 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.writeByte(resourceType); { byte[] _stringBytes = _cache.getSerializedValue(resourceName); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 1) { _writable.writeByte(patternType); } else { if (this.patternType != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default patternType at version " + _version); } } if (_version >= 2) { _writable.writeUnsignedVarint(acls.size() + 1); for (AclDescription aclsElement : acls) { aclsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(acls.size()); for (AclDescription aclsElement : acls) { aclsElement.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; if (_version > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of DescribeAclsResource"); } _size.addBytes(1); { byte[] _stringBytes = resourceName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'resourceName' field is too long to be serialized"); } _cache.cacheSerializedValue(resourceName, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 1) { _size.addBytes(1); } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(acls.size() + 1)); } else { _size.addBytes(4); } for (AclDescription aclsElement : acls) { aclsElement.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 DescribeAclsResource)) return false; DescribeAclsResource other = (DescribeAclsResource) obj; if (resourceType != other.resourceType) return false; if (this.resourceName == null) { if (other.resourceName != null) return false; } else { if (!this.resourceName.equals(other.resourceName)) return false; } if (patternType != other.patternType) return false; if (this.acls == null) { if (other.acls != null) return false; } else { if (!this.acls.equals(other.acls)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + resourceType; hashCode = 31 * hashCode + (resourceName == null ? 0 : resourceName.hashCode()); hashCode = 31 * hashCode + patternType; hashCode = 31 * hashCode + (acls == null ? 0 : acls.hashCode()); return hashCode; } @Override public DescribeAclsResource duplicate() { DescribeAclsResource _duplicate = new DescribeAclsResource(); _duplicate.resourceType = resourceType; _duplicate.resourceName = resourceName; _duplicate.patternType = patternType; ArrayList<AclDescription> newAcls = new ArrayList<AclDescription>(acls.size()); for (AclDescription _element : acls) { newAcls.add(_element.duplicate()); } _duplicate.acls = newAcls; return _duplicate; } @Override public String toString() { return "DescribeAclsResource(" + "resourceType=" + resourceType + ", resourceName=" + ((resourceName == null) ? "null" : "'" + resourceName.toString() + "'") + ", patternType=" + patternType + ", acls=" + MessageUtil.deepToString(acls.iterator()) + ")"; } public byte resourceType() { return this.resourceType; } public String resourceName() { return this.resourceName; } public byte patternType() { return this.patternType; } public List<AclDescription> acls() { return this.acls; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeAclsResource setResourceType(byte v) { this.resourceType = v; return this; } public DescribeAclsResource setResourceName(String v) { this.resourceName = v; return this; } public DescribeAclsResource setPatternType(byte v) { this.patternType = v; return this; } public DescribeAclsResource setAcls(List<AclDescription> v) { this.acls = v; return this; } } public static class AclDescription implements Message { String principal; String host; byte operation; byte permissionType; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("principal", Type.STRING, "The ACL principal."), new Field("host", Type.STRING, "The ACL host."), new Field("operation", Type.INT8, "The ACL operation."), new Field("permission_type", Type.INT8, "The ACL permission type.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("principal", Type.COMPACT_STRING, "The ACL principal."), new Field("host", Type.COMPACT_STRING, "The ACL host."), new Field("operation", Type.INT8, "The ACL operation."), new Field("permission_type", Type.INT8, "The ACL permission type."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public AclDescription(Readable _readable, short _version) { read(_readable, _version); } public AclDescription() { this.principal = ""; this.host = ""; this.operation = (byte) 0; this.permissionType = (byte) 0; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of AclDescription"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principal was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principal had invalid length " + length); } else { this.principal = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field host was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field host had invalid length " + length); } else { this.host = _readable.readString(length); } } this.operation = _readable.readByte(); this.permissionType = _readable.readByte(); 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(principal); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(host); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(operation); _writable.writeByte(permissionType); 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of AclDescription"); } { byte[] _stringBytes = principal.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principal' field is too long to be serialized"); } _cache.cacheSerializedValue(principal, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = host.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'host' field is too long to be serialized"); } _cache.cacheSerializedValue(host, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); _size.addBytes(1); 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 AclDescription)) return false; AclDescription other = (AclDescription) obj; if (this.principal == null) { if (other.principal != null) return false; } else { if (!this.principal.equals(other.principal)) return false; } if (this.host == null) { if (other.host != null) return false; } else { if (!this.host.equals(other.host)) return false; } if (operation != other.operation) return false; if (permissionType != other.permissionType) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (principal == null ? 0 : principal.hashCode()); hashCode = 31 * hashCode + (host == null ? 0 : host.hashCode()); hashCode = 31 * hashCode + operation; hashCode = 31 * hashCode + permissionType; return hashCode; } @Override public AclDescription duplicate() { AclDescription _duplicate = new AclDescription(); _duplicate.principal = principal; _duplicate.host = host; _duplicate.operation = operation; _duplicate.permissionType = permissionType; return _duplicate; } @Override public String toString() { return "AclDescription(" + "principal=" + ((principal == null) ? "null" : "'" + principal.toString() + "'") + ", host=" + ((host == null) ? "null" : "'" + host.toString() + "'") + ", operation=" + operation + ", permissionType=" + permissionType + ")"; } public String principal() { return this.principal; } public String host() { return this.host; } public byte operation() { return this.operation; } public byte permissionType() { return this.permissionType; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public AclDescription setPrincipal(String v) { this.principal = v; return this; } public AclDescription setHost(String v) { this.host = v; return this; } public AclDescription setOperation(byte v) { this.operation = v; return this; } public AclDescription setPermissionType(byte v) { this.permissionType = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeAclsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeAclsResponseData.*; public class DescribeAclsResponseDataJsonConverter { public static DescribeAclsResponseData read(JsonNode _node, short _version) { DescribeAclsResponseData _object = new DescribeAclsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeAclsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeAclsResponseData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeAclsResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeAclsResponseData"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("DescribeAclsResponseData: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DescribeAclsResponseData expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _resourcesNode = _node.get("resources"); if (_resourcesNode == null) { throw new RuntimeException("DescribeAclsResponseData: unable to locate field 'resources', which is mandatory in version " + _version); } else { if (!_resourcesNode.isArray()) { throw new RuntimeException("DescribeAclsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeAclsResource> _collection = new ArrayList<DescribeAclsResource>(_resourcesNode.size()); _object.resources = _collection; for (JsonNode _element : _resourcesNode) { _collection.add(DescribeAclsResourceJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeAclsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } ArrayNode _resourcesArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeAclsResource _element : _object.resources) { _resourcesArray.add(DescribeAclsResourceJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("resources", _resourcesArray); return _node; } public static JsonNode write(DescribeAclsResponseData _object, short _version) { return write(_object, _version, true); } public static class AclDescriptionJsonConverter { public static AclDescription read(JsonNode _node, short _version) { AclDescription _object = new AclDescription(); JsonNode _principalNode = _node.get("principal"); if (_principalNode == null) { throw new RuntimeException("AclDescription: unable to locate field 'principal', which is mandatory in version " + _version); } else { if (!_principalNode.isTextual()) { throw new RuntimeException("AclDescription expected a string type, but got " + _node.getNodeType()); } _object.principal = _principalNode.asText(); } JsonNode _hostNode = _node.get("host"); if (_hostNode == null) { throw new RuntimeException("AclDescription: unable to locate field 'host', which is mandatory in version " + _version); } else { if (!_hostNode.isTextual()) { throw new RuntimeException("AclDescription expected a string type, but got " + _node.getNodeType()); } _object.host = _hostNode.asText(); } JsonNode _operationNode = _node.get("operation"); if (_operationNode == null) { throw new RuntimeException("AclDescription: unable to locate field 'operation', which is mandatory in version " + _version); } else { _object.operation = MessageUtil.jsonNodeToByte(_operationNode, "AclDescription"); } JsonNode _permissionTypeNode = _node.get("permissionType"); if (_permissionTypeNode == null) { throw new RuntimeException("AclDescription: unable to locate field 'permissionType', which is mandatory in version " + _version); } else { _object.permissionType = MessageUtil.jsonNodeToByte(_permissionTypeNode, "AclDescription"); } return _object; } public static JsonNode write(AclDescription _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("principal", new TextNode(_object.principal)); _node.set("host", new TextNode(_object.host)); _node.set("operation", new ShortNode(_object.operation)); _node.set("permissionType", new ShortNode(_object.permissionType)); return _node; } public static JsonNode write(AclDescription _object, short _version) { return write(_object, _version, true); } } public static class DescribeAclsResourceJsonConverter { public static DescribeAclsResource read(JsonNode _node, short _version) { DescribeAclsResource _object = new DescribeAclsResource(); JsonNode _resourceTypeNode = _node.get("resourceType"); if (_resourceTypeNode == null) { throw new RuntimeException("DescribeAclsResource: unable to locate field 'resourceType', which is mandatory in version " + _version); } else { _object.resourceType = MessageUtil.jsonNodeToByte(_resourceTypeNode, "DescribeAclsResource"); } JsonNode _resourceNameNode = _node.get("resourceName"); if (_resourceNameNode == null) { throw new RuntimeException("DescribeAclsResource: unable to locate field 'resourceName', which is mandatory in version " + _version); } else { if (!_resourceNameNode.isTextual()) { throw new RuntimeException("DescribeAclsResource expected a string type, but got " + _node.getNodeType()); } _object.resourceName = _resourceNameNode.asText(); } JsonNode _patternTypeNode = _node.get("patternType"); if (_patternTypeNode == null) { if (_version >= 1) { throw new RuntimeException("DescribeAclsResource: unable to locate field 'patternType', which is mandatory in version " + _version); } else { _object.patternType = (byte) 3; } } else { _object.patternType = MessageUtil.jsonNodeToByte(_patternTypeNode, "DescribeAclsResource"); } JsonNode _aclsNode = _node.get("acls"); if (_aclsNode == null) { throw new RuntimeException("DescribeAclsResource: unable to locate field 'acls', which is mandatory in version " + _version); } else { if (!_aclsNode.isArray()) { throw new RuntimeException("DescribeAclsResource expected a JSON array, but got " + _node.getNodeType()); } ArrayList<AclDescription> _collection = new ArrayList<AclDescription>(_aclsNode.size()); _object.acls = _collection; for (JsonNode _element : _aclsNode) { _collection.add(AclDescriptionJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeAclsResource _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("resourceType", new ShortNode(_object.resourceType)); _node.set("resourceName", new TextNode(_object.resourceName)); if (_version >= 1) { _node.set("patternType", new ShortNode(_object.patternType)); } else { if (_object.patternType != (byte) 3) { throw new UnsupportedVersionException("Attempted to write a non-default patternType at version " + _version); } } ArrayNode _aclsArray = new ArrayNode(JsonNodeFactory.instance); for (AclDescription _element : _object.acls) { _aclsArray.add(AclDescriptionJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("acls", _aclsArray); return _node; } public static JsonNode write(DescribeAclsResource _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeClientQuotasRequestData.java
/* * 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 DescribeClientQuotasRequestData implements ApiMessage { List<ComponentData> components; boolean strict; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("components", new ArrayOf(ComponentData.SCHEMA_0), "Filter components to apply to quota entities."), new Field("strict", Type.BOOLEAN, "Whether the match is strict, i.e. should exclude entities with unspecified entity types.") ); public static final Schema SCHEMA_1 = new Schema( new Field("components", new CompactArrayOf(ComponentData.SCHEMA_1), "Filter components to apply to quota entities."), new Field("strict", Type.BOOLEAN, "Whether the match is strict, i.e. should exclude entities with unspecified entity types."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public DescribeClientQuotasRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeClientQuotasRequestData() { this.components = new ArrayList<ComponentData>(0); this.strict = false; } @Override public short apiKey() { return 48; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { { if (_version >= 1) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field components 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<ComponentData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ComponentData(_readable, _version)); } this.components = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field components 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<ComponentData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ComponentData(_readable, _version)); } this.components = newCollection; } } } this.strict = _readable.readByte() != 0; this._unknownTaggedFields = null; if (_version >= 1) { 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; if (_version >= 1) { _writable.writeUnsignedVarint(components.size() + 1); for (ComponentData componentsElement : components) { componentsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(components.size()); for (ComponentData componentsElement : components) { componentsElement.write(_writable, _cache, _version); } } _writable.writeByte(strict ? (byte) 1 : (byte) 0); RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 1) { _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 >= 1) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(components.size() + 1)); } else { _size.addBytes(4); } for (ComponentData componentsElement : components) { componentsElement.addSize(_size, _cache, _version); } } _size.addBytes(1); 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 >= 1) { _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 DescribeClientQuotasRequestData)) return false; DescribeClientQuotasRequestData other = (DescribeClientQuotasRequestData) obj; if (this.components == null) { if (other.components != null) return false; } else { if (!this.components.equals(other.components)) return false; } if (strict != other.strict) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (components == null ? 0 : components.hashCode()); hashCode = 31 * hashCode + (strict ? 1231 : 1237); return hashCode; } @Override public DescribeClientQuotasRequestData duplicate() { DescribeClientQuotasRequestData _duplicate = new DescribeClientQuotasRequestData(); ArrayList<ComponentData> newComponents = new ArrayList<ComponentData>(components.size()); for (ComponentData _element : components) { newComponents.add(_element.duplicate()); } _duplicate.components = newComponents; _duplicate.strict = strict; return _duplicate; } @Override public String toString() { return "DescribeClientQuotasRequestData(" + "components=" + MessageUtil.deepToString(components.iterator()) + ", strict=" + (strict ? "true" : "false") + ")"; } public List<ComponentData> components() { return this.components; } public boolean strict() { return this.strict; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeClientQuotasRequestData setComponents(List<ComponentData> v) { this.components = v; return this; } public DescribeClientQuotasRequestData setStrict(boolean v) { this.strict = v; return this; } public static class ComponentData implements Message { String entityType; byte matchType; String match; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("entity_type", Type.STRING, "The entity type that the filter component applies to."), new Field("match_type", Type.INT8, "How to match the entity {0 = exact name, 1 = default name, 2 = any specified name}."), new Field("match", Type.NULLABLE_STRING, "The string to match against, or null if unused for the match type.") ); public static final Schema SCHEMA_1 = new Schema( new Field("entity_type", Type.COMPACT_STRING, "The entity type that the filter component applies to."), new Field("match_type", Type.INT8, "How to match the entity {0 = exact name, 1 = default name, 2 = any specified name}."), new Field("match", Type.COMPACT_NULLABLE_STRING, "The string to match against, or null if unused for the match type."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public ComponentData(Readable _readable, short _version) { read(_readable, _version); } public ComponentData() { this.entityType = ""; this.matchType = (byte) 0; this.match = ""; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { if (_version > 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of ComponentData"); } { int length; if (_version >= 1) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field entityType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field entityType had invalid length " + length); } else { this.entityType = _readable.readString(length); } } this.matchType = _readable.readByte(); { int length; if (_version >= 1) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.match = null; } else if (length > 0x7fff) { throw new RuntimeException("string field match had invalid length " + length); } else { this.match = _readable.readString(length); } } this._unknownTaggedFields = null; if (_version >= 1) { 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(entityType); if (_version >= 1) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(matchType); if (match == null) { if (_version >= 1) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(match); if (_version >= 1) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 1) { _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 > 1) { throw new UnsupportedVersionException("Can't size version " + _version + " of ComponentData"); } { byte[] _stringBytes = entityType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'entityType' field is too long to be serialized"); } _cache.cacheSerializedValue(entityType, _stringBytes); if (_version >= 1) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); if (match == null) { if (_version >= 1) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = match.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'match' field is too long to be serialized"); } _cache.cacheSerializedValue(match, _stringBytes); if (_version >= 1) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 >= 1) { _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 ComponentData)) return false; ComponentData other = (ComponentData) obj; if (this.entityType == null) { if (other.entityType != null) return false; } else { if (!this.entityType.equals(other.entityType)) return false; } if (matchType != other.matchType) return false; if (this.match == null) { if (other.match != null) return false; } else { if (!this.match.equals(other.match)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (entityType == null ? 0 : entityType.hashCode()); hashCode = 31 * hashCode + matchType; hashCode = 31 * hashCode + (match == null ? 0 : match.hashCode()); return hashCode; } @Override public ComponentData duplicate() { ComponentData _duplicate = new ComponentData(); _duplicate.entityType = entityType; _duplicate.matchType = matchType; if (match == null) { _duplicate.match = null; } else { _duplicate.match = match; } return _duplicate; } @Override public String toString() { return "ComponentData(" + "entityType=" + ((entityType == null) ? "null" : "'" + entityType.toString() + "'") + ", matchType=" + matchType + ", match=" + ((match == null) ? "null" : "'" + match.toString() + "'") + ")"; } public String entityType() { return this.entityType; } public byte matchType() { return this.matchType; } public String match() { return this.match; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ComponentData setEntityType(String v) { this.entityType = v; return this; } public ComponentData setMatchType(byte v) { this.matchType = v; return this; } public ComponentData setMatch(String v) { this.match = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeClientQuotasRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeClientQuotasRequestData.*; public class DescribeClientQuotasRequestDataJsonConverter { public static DescribeClientQuotasRequestData read(JsonNode _node, short _version) { DescribeClientQuotasRequestData _object = new DescribeClientQuotasRequestData(); JsonNode _componentsNode = _node.get("components"); if (_componentsNode == null) { throw new RuntimeException("DescribeClientQuotasRequestData: unable to locate field 'components', which is mandatory in version " + _version); } else { if (!_componentsNode.isArray()) { throw new RuntimeException("DescribeClientQuotasRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<ComponentData> _collection = new ArrayList<ComponentData>(_componentsNode.size()); _object.components = _collection; for (JsonNode _element : _componentsNode) { _collection.add(ComponentDataJsonConverter.read(_element, _version)); } } JsonNode _strictNode = _node.get("strict"); if (_strictNode == null) { throw new RuntimeException("DescribeClientQuotasRequestData: unable to locate field 'strict', which is mandatory in version " + _version); } else { if (!_strictNode.isBoolean()) { throw new RuntimeException("DescribeClientQuotasRequestData expected Boolean type, but got " + _node.getNodeType()); } _object.strict = _strictNode.asBoolean(); } return _object; } public static JsonNode write(DescribeClientQuotasRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _componentsArray = new ArrayNode(JsonNodeFactory.instance); for (ComponentData _element : _object.components) { _componentsArray.add(ComponentDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("components", _componentsArray); _node.set("strict", BooleanNode.valueOf(_object.strict)); return _node; } public static JsonNode write(DescribeClientQuotasRequestData _object, short _version) { return write(_object, _version, true); } public static class ComponentDataJsonConverter { public static ComponentData read(JsonNode _node, short _version) { ComponentData _object = new ComponentData(); JsonNode _entityTypeNode = _node.get("entityType"); if (_entityTypeNode == null) { throw new RuntimeException("ComponentData: unable to locate field 'entityType', which is mandatory in version " + _version); } else { if (!_entityTypeNode.isTextual()) { throw new RuntimeException("ComponentData expected a string type, but got " + _node.getNodeType()); } _object.entityType = _entityTypeNode.asText(); } JsonNode _matchTypeNode = _node.get("matchType"); if (_matchTypeNode == null) { throw new RuntimeException("ComponentData: unable to locate field 'matchType', which is mandatory in version " + _version); } else { _object.matchType = MessageUtil.jsonNodeToByte(_matchTypeNode, "ComponentData"); } JsonNode _matchNode = _node.get("match"); if (_matchNode == null) { throw new RuntimeException("ComponentData: unable to locate field 'match', which is mandatory in version " + _version); } else { if (_matchNode.isNull()) { _object.match = null; } else { if (!_matchNode.isTextual()) { throw new RuntimeException("ComponentData expected a string type, but got " + _node.getNodeType()); } _object.match = _matchNode.asText(); } } return _object; } public static JsonNode write(ComponentData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("entityType", new TextNode(_object.entityType)); _node.set("matchType", new ShortNode(_object.matchType)); if (_object.match == null) { _node.set("match", NullNode.instance); } else { _node.set("match", new TextNode(_object.match)); } return _node; } public static JsonNode write(ComponentData _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeClientQuotasResponseData.java
/* * 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 DescribeClientQuotasResponseData implements ApiMessage { int throttleTimeMs; short errorCode; String errorMessage; List<EntryData> entries; private List<RawTaggedField> _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 error code, or `0` if the quota description succeeded."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or `null` if the quota description succeeded."), new Field("entries", ArrayOf.nullable(EntryData.SCHEMA_0), "A result entry.") ); public static final Schema SCHEMA_1 = 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 error code, or `0` if the quota description succeeded."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The error message, or `null` if the quota description succeeded."), new Field("entries", CompactArrayOf.nullable(EntryData.SCHEMA_1), "A result entry."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public DescribeClientQuotasResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeClientQuotasResponseData() { this.throttleTimeMs = 0; this.errorCode = (short) 0; this.errorMessage = ""; this.entries = new ArrayList<EntryData>(0); } @Override public short apiKey() { return 48; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); this.errorCode = _readable.readShort(); { int length; if (_version >= 1) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } { if (_version >= 1) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.entries = 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<EntryData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new EntryData(_readable, _version)); } this.entries = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { this.entries = 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<EntryData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new EntryData(_readable, _version)); } this.entries = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 1) { 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) { if (_version >= 1) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 1) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 1) { if (entries == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(entries.size() + 1); for (EntryData entriesElement : entries) { entriesElement.write(_writable, _cache, _version); } } } else { if (entries == null) { _writable.writeInt(-1); } else { _writable.writeInt(entries.size()); for (EntryData entriesElement : entries) { entriesElement.write(_writable, _cache, _version); } } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 1) { _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(4); _size.addBytes(2); if (errorMessage == null) { if (_version >= 1) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 1) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (entries == null) { if (_version >= 1) { _size.addBytes(1); } else { _size.addBytes(4); } } else { if (_version >= 1) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(entries.size() + 1)); } else { _size.addBytes(4); } for (EntryData entriesElement : entries) { entriesElement.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 >= 1) { _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 DescribeClientQuotasResponseData)) return false; DescribeClientQuotasResponseData other = (DescribeClientQuotasResponseData) 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.entries == null) { if (other.entries != null) return false; } else { if (!this.entries.equals(other.entries)) 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 + (entries == null ? 0 : entries.hashCode()); return hashCode; } @Override public DescribeClientQuotasResponseData duplicate() { DescribeClientQuotasResponseData _duplicate = new DescribeClientQuotasResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } if (entries == null) { _duplicate.entries = null; } else { ArrayList<EntryData> newEntries = new ArrayList<EntryData>(entries.size()); for (EntryData _element : entries) { newEntries.add(_element.duplicate()); } _duplicate.entries = newEntries; } return _duplicate; } @Override public String toString() { return "DescribeClientQuotasResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", entries=" + ((entries == null) ? "null" : MessageUtil.deepToString(entries.iterator())) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public List<EntryData> entries() { return this.entries; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeClientQuotasResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeClientQuotasResponseData setErrorCode(short v) { this.errorCode = v; return this; } public DescribeClientQuotasResponseData setErrorMessage(String v) { this.errorMessage = v; return this; } public DescribeClientQuotasResponseData setEntries(List<EntryData> v) { this.entries = v; return this; } public static class EntryData implements Message { List<EntityData> entity; List<ValueData> values; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("entity", new ArrayOf(EntityData.SCHEMA_0), "The quota entity description."), new Field("values", new ArrayOf(ValueData.SCHEMA_0), "The quota values for the entity.") ); public static final Schema SCHEMA_1 = new Schema( new Field("entity", new CompactArrayOf(EntityData.SCHEMA_1), "The quota entity description."), new Field("values", new CompactArrayOf(ValueData.SCHEMA_1), "The quota values for the entity."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public EntryData(Readable _readable, short _version) { read(_readable, _version); } public EntryData() { this.entity = new ArrayList<EntityData>(0); this.values = new ArrayList<ValueData>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { if (_version > 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of EntryData"); } { if (_version >= 1) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field entity 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<EntityData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new EntityData(_readable, _version)); } this.entity = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field entity 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<EntityData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new EntityData(_readable, _version)); } this.entity = newCollection; } } } { if (_version >= 1) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field values 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<ValueData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ValueData(_readable, _version)); } this.values = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field values 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<ValueData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ValueData(_readable, _version)); } this.values = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 1) { 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; if (_version >= 1) { _writable.writeUnsignedVarint(entity.size() + 1); for (EntityData entityElement : entity) { entityElement.write(_writable, _cache, _version); } } else { _writable.writeInt(entity.size()); for (EntityData entityElement : entity) { entityElement.write(_writable, _cache, _version); } } if (_version >= 1) { _writable.writeUnsignedVarint(values.size() + 1); for (ValueData valuesElement : values) { valuesElement.write(_writable, _cache, _version); } } else { _writable.writeInt(values.size()); for (ValueData valuesElement : values) { valuesElement.write(_writable, _cache, _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 1) { _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 > 1) { throw new UnsupportedVersionException("Can't size version " + _version + " of EntryData"); } { if (_version >= 1) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(entity.size() + 1)); } else { _size.addBytes(4); } for (EntityData entityElement : entity) { entityElement.addSize(_size, _cache, _version); } } { if (_version >= 1) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(values.size() + 1)); } else { _size.addBytes(4); } for (ValueData valuesElement : values) { valuesElement.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 >= 1) { _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 EntryData)) return false; EntryData other = (EntryData) obj; if (this.entity == null) { if (other.entity != null) return false; } else { if (!this.entity.equals(other.entity)) return false; } if (this.values == null) { if (other.values != null) return false; } else { if (!this.values.equals(other.values)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (entity == null ? 0 : entity.hashCode()); hashCode = 31 * hashCode + (values == null ? 0 : values.hashCode()); return hashCode; } @Override public EntryData duplicate() { EntryData _duplicate = new EntryData(); ArrayList<EntityData> newEntity = new ArrayList<EntityData>(entity.size()); for (EntityData _element : entity) { newEntity.add(_element.duplicate()); } _duplicate.entity = newEntity; ArrayList<ValueData> newValues = new ArrayList<ValueData>(values.size()); for (ValueData _element : values) { newValues.add(_element.duplicate()); } _duplicate.values = newValues; return _duplicate; } @Override public String toString() { return "EntryData(" + "entity=" + MessageUtil.deepToString(entity.iterator()) + ", values=" + MessageUtil.deepToString(values.iterator()) + ")"; } public List<EntityData> entity() { return this.entity; } public List<ValueData> values() { return this.values; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public EntryData setEntity(List<EntityData> v) { this.entity = v; return this; } public EntryData setValues(List<ValueData> v) { this.values = v; return this; } } public static class EntityData implements Message { String entityType; String entityName; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("entity_type", Type.STRING, "The entity type."), new Field("entity_name", Type.NULLABLE_STRING, "The entity name, or null if the default.") ); public static final Schema SCHEMA_1 = new Schema( new Field("entity_type", Type.COMPACT_STRING, "The entity type."), new Field("entity_name", Type.COMPACT_NULLABLE_STRING, "The entity name, or null if the default."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public EntityData(Readable _readable, short _version) { read(_readable, _version); } public EntityData() { this.entityType = ""; this.entityName = ""; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { if (_version > 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of EntityData"); } { int length; if (_version >= 1) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field entityType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field entityType had invalid length " + length); } else { this.entityType = _readable.readString(length); } } { int length; if (_version >= 1) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.entityName = null; } else if (length > 0x7fff) { throw new RuntimeException("string field entityName had invalid length " + length); } else { this.entityName = _readable.readString(length); } } this._unknownTaggedFields = null; if (_version >= 1) { 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(entityType); if (_version >= 1) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (entityName == null) { if (_version >= 1) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(entityName); if (_version >= 1) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 1) { _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 > 1) { throw new UnsupportedVersionException("Can't size version " + _version + " of EntityData"); } { byte[] _stringBytes = entityType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'entityType' field is too long to be serialized"); } _cache.cacheSerializedValue(entityType, _stringBytes); if (_version >= 1) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (entityName == null) { if (_version >= 1) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = entityName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'entityName' field is too long to be serialized"); } _cache.cacheSerializedValue(entityName, _stringBytes); if (_version >= 1) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 >= 1) { _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 EntityData)) return false; EntityData other = (EntityData) obj; if (this.entityType == null) { if (other.entityType != null) return false; } else { if (!this.entityType.equals(other.entityType)) return false; } if (this.entityName == null) { if (other.entityName != null) return false; } else { if (!this.entityName.equals(other.entityName)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (entityType == null ? 0 : entityType.hashCode()); hashCode = 31 * hashCode + (entityName == null ? 0 : entityName.hashCode()); return hashCode; } @Override public EntityData duplicate() { EntityData _duplicate = new EntityData(); _duplicate.entityType = entityType; if (entityName == null) { _duplicate.entityName = null; } else { _duplicate.entityName = entityName; } return _duplicate; } @Override public String toString() { return "EntityData(" + "entityType=" + ((entityType == null) ? "null" : "'" + entityType.toString() + "'") + ", entityName=" + ((entityName == null) ? "null" : "'" + entityName.toString() + "'") + ")"; } public String entityType() { return this.entityType; } public String entityName() { return this.entityName; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public EntityData setEntityType(String v) { this.entityType = v; return this; } public EntityData setEntityName(String v) { this.entityName = v; return this; } } public static class ValueData implements Message { String key; double value; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("key", Type.STRING, "The quota configuration key."), new Field("value", Type.FLOAT64, "The quota configuration value.") ); public static final Schema SCHEMA_1 = new Schema( new Field("key", Type.COMPACT_STRING, "The quota configuration key."), new Field("value", Type.FLOAT64, "The quota configuration value."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public ValueData(Readable _readable, short _version) { read(_readable, _version); } public ValueData() { this.key = ""; this.value = 0.0; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { if (_version > 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of ValueData"); } { int length; if (_version >= 1) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field key was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field key had invalid length " + length); } else { this.key = _readable.readString(length); } } this.value = _readable.readDouble(); this._unknownTaggedFields = null; if (_version >= 1) { 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(key); if (_version >= 1) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeDouble(value); RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 1) { _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 > 1) { throw new UnsupportedVersionException("Can't size version " + _version + " of ValueData"); } { byte[] _stringBytes = key.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'key' field is too long to be serialized"); } _cache.cacheSerializedValue(key, _stringBytes); if (_version >= 1) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(8); 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 >= 1) { _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 ValueData)) return false; ValueData other = (ValueData) obj; if (this.key == null) { if (other.key != null) return false; } else { if (!this.key.equals(other.key)) return false; } if (value != other.value) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (key == null ? 0 : key.hashCode()); hashCode = 31 * hashCode + Double.hashCode(value); return hashCode; } @Override public ValueData duplicate() { ValueData _duplicate = new ValueData(); _duplicate.key = key; _duplicate.value = value; return _duplicate; } @Override public String toString() { return "ValueData(" + "key=" + ((key == null) ? "null" : "'" + key.toString() + "'") + ", value=" + value + ")"; } public String key() { return this.key; } public double value() { return this.value; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ValueData setKey(String v) { this.key = v; return this; } public ValueData setValue(double v) { this.value = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeClientQuotasResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.DoubleNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeClientQuotasResponseData.*; public class DescribeClientQuotasResponseDataJsonConverter { public static DescribeClientQuotasResponseData read(JsonNode _node, short _version) { DescribeClientQuotasResponseData _object = new DescribeClientQuotasResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeClientQuotasResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeClientQuotasResponseData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeClientQuotasResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeClientQuotasResponseData"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("DescribeClientQuotasResponseData: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DescribeClientQuotasResponseData expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _entriesNode = _node.get("entries"); if (_entriesNode == null) { throw new RuntimeException("DescribeClientQuotasResponseData: unable to locate field 'entries', which is mandatory in version " + _version); } else { if (_entriesNode.isNull()) { _object.entries = null; } else { if (!_entriesNode.isArray()) { throw new RuntimeException("DescribeClientQuotasResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<EntryData> _collection = new ArrayList<EntryData>(_entriesNode.size()); _object.entries = _collection; for (JsonNode _element : _entriesNode) { _collection.add(EntryDataJsonConverter.read(_element, _version)); } } } return _object; } public static JsonNode write(DescribeClientQuotasResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } if (_object.entries == null) { _node.set("entries", NullNode.instance); } else { ArrayNode _entriesArray = new ArrayNode(JsonNodeFactory.instance); for (EntryData _element : _object.entries) { _entriesArray.add(EntryDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("entries", _entriesArray); } return _node; } public static JsonNode write(DescribeClientQuotasResponseData _object, short _version) { return write(_object, _version, true); } public static class EntityDataJsonConverter { public static EntityData read(JsonNode _node, short _version) { EntityData _object = new EntityData(); JsonNode _entityTypeNode = _node.get("entityType"); if (_entityTypeNode == null) { throw new RuntimeException("EntityData: unable to locate field 'entityType', which is mandatory in version " + _version); } else { if (!_entityTypeNode.isTextual()) { throw new RuntimeException("EntityData expected a string type, but got " + _node.getNodeType()); } _object.entityType = _entityTypeNode.asText(); } JsonNode _entityNameNode = _node.get("entityName"); if (_entityNameNode == null) { throw new RuntimeException("EntityData: unable to locate field 'entityName', which is mandatory in version " + _version); } else { if (_entityNameNode.isNull()) { _object.entityName = null; } else { if (!_entityNameNode.isTextual()) { throw new RuntimeException("EntityData expected a string type, but got " + _node.getNodeType()); } _object.entityName = _entityNameNode.asText(); } } return _object; } public static JsonNode write(EntityData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("entityType", new TextNode(_object.entityType)); if (_object.entityName == null) { _node.set("entityName", NullNode.instance); } else { _node.set("entityName", new TextNode(_object.entityName)); } return _node; } public static JsonNode write(EntityData _object, short _version) { return write(_object, _version, true); } } public static class EntryDataJsonConverter { public static EntryData read(JsonNode _node, short _version) { EntryData _object = new EntryData(); JsonNode _entityNode = _node.get("entity"); if (_entityNode == null) { throw new RuntimeException("EntryData: unable to locate field 'entity', which is mandatory in version " + _version); } else { if (!_entityNode.isArray()) { throw new RuntimeException("EntryData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<EntityData> _collection = new ArrayList<EntityData>(_entityNode.size()); _object.entity = _collection; for (JsonNode _element : _entityNode) { _collection.add(EntityDataJsonConverter.read(_element, _version)); } } JsonNode _valuesNode = _node.get("values"); if (_valuesNode == null) { throw new RuntimeException("EntryData: unable to locate field 'values', which is mandatory in version " + _version); } else { if (!_valuesNode.isArray()) { throw new RuntimeException("EntryData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<ValueData> _collection = new ArrayList<ValueData>(_valuesNode.size()); _object.values = _collection; for (JsonNode _element : _valuesNode) { _collection.add(ValueDataJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(EntryData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _entityArray = new ArrayNode(JsonNodeFactory.instance); for (EntityData _element : _object.entity) { _entityArray.add(EntityDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("entity", _entityArray); ArrayNode _valuesArray = new ArrayNode(JsonNodeFactory.instance); for (ValueData _element : _object.values) { _valuesArray.add(ValueDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("values", _valuesArray); return _node; } public static JsonNode write(EntryData _object, short _version) { return write(_object, _version, true); } } public static class ValueDataJsonConverter { public static ValueData read(JsonNode _node, short _version) { ValueData _object = new ValueData(); JsonNode _keyNode = _node.get("key"); if (_keyNode == null) { throw new RuntimeException("ValueData: unable to locate field 'key', which is mandatory in version " + _version); } else { if (!_keyNode.isTextual()) { throw new RuntimeException("ValueData expected a string type, but got " + _node.getNodeType()); } _object.key = _keyNode.asText(); } JsonNode _valueNode = _node.get("value"); if (_valueNode == null) { throw new RuntimeException("ValueData: unable to locate field 'value', which is mandatory in version " + _version); } else { _object.value = MessageUtil.jsonNodeToDouble(_valueNode, "ValueData"); } return _object; } public static JsonNode write(ValueData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("key", new TextNode(_object.key)); _node.set("value", new DoubleNode(_object.value)); return _node; } public static JsonNode write(ValueData _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeClusterRequestData.java
/* * 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.util.ArrayList; import java.util.List; import org.apache.kafka.common.protocol.ApiMessage; 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.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 DescribeClusterRequestData implements ApiMessage { boolean includeClusterAuthorizedOperations; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("include_cluster_authorized_operations", Type.BOOLEAN, "Whether to include cluster authorized operations."), 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 DescribeClusterRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeClusterRequestData() { this.includeClusterAuthorizedOperations = false; } @Override public short apiKey() { return 60; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { this.includeClusterAuthorizedOperations = _readable.readByte() != 0; 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.writeByte(includeClusterAuthorizedOperations ? (byte) 1 : (byte) 0); 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(1); 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 DescribeClusterRequestData)) return false; DescribeClusterRequestData other = (DescribeClusterRequestData) obj; if (includeClusterAuthorizedOperations != other.includeClusterAuthorizedOperations) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (includeClusterAuthorizedOperations ? 1231 : 1237); return hashCode; } @Override public DescribeClusterRequestData duplicate() { DescribeClusterRequestData _duplicate = new DescribeClusterRequestData(); _duplicate.includeClusterAuthorizedOperations = includeClusterAuthorizedOperations; return _duplicate; } @Override public String toString() { return "DescribeClusterRequestData(" + "includeClusterAuthorizedOperations=" + (includeClusterAuthorizedOperations ? "true" : "false") + ")"; } public boolean includeClusterAuthorizedOperations() { return this.includeClusterAuthorizedOperations; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeClusterRequestData setIncludeClusterAuthorizedOperations(boolean v) { this.includeClusterAuthorizedOperations = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeClusterRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import static org.apache.kafka.common.message.DescribeClusterRequestData.*; public class DescribeClusterRequestDataJsonConverter { public static DescribeClusterRequestData read(JsonNode _node, short _version) { DescribeClusterRequestData _object = new DescribeClusterRequestData(); JsonNode _includeClusterAuthorizedOperationsNode = _node.get("includeClusterAuthorizedOperations"); if (_includeClusterAuthorizedOperationsNode == null) { throw new RuntimeException("DescribeClusterRequestData: unable to locate field 'includeClusterAuthorizedOperations', which is mandatory in version " + _version); } else { if (!_includeClusterAuthorizedOperationsNode.isBoolean()) { throw new RuntimeException("DescribeClusterRequestData expected Boolean type, but got " + _node.getNodeType()); } _object.includeClusterAuthorizedOperations = _includeClusterAuthorizedOperationsNode.asBoolean(); } return _object; } public static JsonNode write(DescribeClusterRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("includeClusterAuthorizedOperations", BooleanNode.valueOf(_object.includeClusterAuthorizedOperations)); return _node; } public static JsonNode write(DescribeClusterRequestData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeClusterResponseData.java
/* * 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.Iterator; 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.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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class DescribeClusterResponseData implements ApiMessage { int throttleTimeMs; short errorCode; String errorMessage; String clusterId; int controllerId; DescribeClusterBrokerCollection brokers; int clusterAuthorizedOperations; private List<RawTaggedField> _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("cluster_id", Type.COMPACT_STRING, "The cluster ID that responding broker belongs to."), new Field("controller_id", Type.INT32, "The ID of the controller broker."), new Field("brokers", new CompactArrayOf(DescribeClusterBroker.SCHEMA_0), "Each broker in the response."), new Field("cluster_authorized_operations", Type.INT32, "32-bit bitfield to represent authorized operations for this cluster."), 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 DescribeClusterResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeClusterResponseData() { this.throttleTimeMs = 0; this.errorCode = (short) 0; this.errorMessage = null; this.clusterId = ""; this.controllerId = -1; this.brokers = new DescribeClusterBrokerCollection(0); this.clusterAuthorizedOperations = -2147483648; } @Override public short apiKey() { return 60; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public 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) { throw new RuntimeException("non-nullable field clusterId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field clusterId had invalid length " + length); } else { this.clusterId = _readable.readString(length); } } this.controllerId = _readable.readInt(); { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field brokers 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."); } DescribeClusterBrokerCollection newCollection = new DescribeClusterBrokerCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeClusterBroker(_readable, _version)); } this.brokers = newCollection; } } this.clusterAuthorizedOperations = _readable.readInt(); 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); } { byte[] _stringBytes = _cache.getSerializedValue(clusterId); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeInt(controllerId); _writable.writeUnsignedVarint(brokers.size() + 1); for (DescribeClusterBroker brokersElement : brokers) { brokersElement.write(_writable, _cache, _version); } _writable.writeInt(clusterAuthorizedOperations); 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)); } { byte[] _stringBytes = clusterId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'clusterId' field is too long to be serialized"); } _cache.cacheSerializedValue(clusterId, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _size.addBytes(4); { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(brokers.size() + 1)); for (DescribeClusterBroker brokersElement : brokers) { brokersElement.addSize(_size, _cache, _version); } } _size.addBytes(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 DescribeClusterResponseData)) return false; DescribeClusterResponseData other = (DescribeClusterResponseData) 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.clusterId == null) { if (other.clusterId != null) return false; } else { if (!this.clusterId.equals(other.clusterId)) return false; } if (controllerId != other.controllerId) return false; if (this.brokers == null) { if (other.brokers != null) return false; } else { if (!this.brokers.equals(other.brokers)) return false; } if (clusterAuthorizedOperations != other.clusterAuthorizedOperations) 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 + (clusterId == null ? 0 : clusterId.hashCode()); hashCode = 31 * hashCode + controllerId; hashCode = 31 * hashCode + (brokers == null ? 0 : brokers.hashCode()); hashCode = 31 * hashCode + clusterAuthorizedOperations; return hashCode; } @Override public DescribeClusterResponseData duplicate() { DescribeClusterResponseData _duplicate = new DescribeClusterResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } _duplicate.clusterId = clusterId; _duplicate.controllerId = controllerId; DescribeClusterBrokerCollection newBrokers = new DescribeClusterBrokerCollection(brokers.size()); for (DescribeClusterBroker _element : brokers) { newBrokers.add(_element.duplicate()); } _duplicate.brokers = newBrokers; _duplicate.clusterAuthorizedOperations = clusterAuthorizedOperations; return _duplicate; } @Override public String toString() { return "DescribeClusterResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", clusterId=" + ((clusterId == null) ? "null" : "'" + clusterId.toString() + "'") + ", controllerId=" + controllerId + ", brokers=" + MessageUtil.deepToString(brokers.iterator()) + ", clusterAuthorizedOperations=" + clusterAuthorizedOperations + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public String clusterId() { return this.clusterId; } public int controllerId() { return this.controllerId; } public DescribeClusterBrokerCollection brokers() { return this.brokers; } public int clusterAuthorizedOperations() { return this.clusterAuthorizedOperations; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeClusterResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeClusterResponseData setErrorCode(short v) { this.errorCode = v; return this; } public DescribeClusterResponseData setErrorMessage(String v) { this.errorMessage = v; return this; } public DescribeClusterResponseData setClusterId(String v) { this.clusterId = v; return this; } public DescribeClusterResponseData setControllerId(int v) { this.controllerId = v; return this; } public DescribeClusterResponseData setBrokers(DescribeClusterBrokerCollection v) { this.brokers = v; return this; } public DescribeClusterResponseData setClusterAuthorizedOperations(int v) { this.clusterAuthorizedOperations = v; return this; } public static class DescribeClusterBroker implements Message, ImplicitLinkedHashMultiCollection.Element { int brokerId; String host; int port; String rack; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("broker_id", Type.INT32, "The broker ID."), new Field("host", Type.COMPACT_STRING, "The broker hostname."), new Field("port", Type.INT32, "The broker port."), new Field("rack", Type.COMPACT_NULLABLE_STRING, "The rack of the broker, or null if it has not been assigned to a rack."), 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 DescribeClusterBroker(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public DescribeClusterBroker() { this.brokerId = 0; this.host = ""; this.port = 0; this.rack = null; this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribeClusterBroker"); } this.brokerId = _readable.readInt(); { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field host was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field host had invalid length " + length); } else { this.host = _readable.readString(length); } } this.port = _readable.readInt(); { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { this.rack = null; } else if (length > 0x7fff) { throw new RuntimeException("string field rack had invalid length " + length); } else { this.rack = _readable.readString(length); } } 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(brokerId); { byte[] _stringBytes = _cache.getSerializedValue(host); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeInt(port); if (rack == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(rack); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } 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 DescribeClusterBroker"); } _size.addBytes(4); { byte[] _stringBytes = host.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'host' field is too long to be serialized"); } _cache.cacheSerializedValue(host, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _size.addBytes(4); if (rack == null) { _size.addBytes(1); } else { byte[] _stringBytes = rack.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'rack' field is too long to be serialized"); } _cache.cacheSerializedValue(rack, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } 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 elementKeysAreEqual(Object obj) { if (!(obj instanceof DescribeClusterBroker)) return false; DescribeClusterBroker other = (DescribeClusterBroker) obj; if (brokerId != other.brokerId) return false; return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof DescribeClusterBroker)) return false; DescribeClusterBroker other = (DescribeClusterBroker) obj; if (brokerId != other.brokerId) return false; if (this.host == null) { if (other.host != null) return false; } else { if (!this.host.equals(other.host)) return false; } if (port != other.port) return false; if (this.rack == null) { if (other.rack != null) return false; } else { if (!this.rack.equals(other.rack)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + brokerId; return hashCode; } @Override public DescribeClusterBroker duplicate() { DescribeClusterBroker _duplicate = new DescribeClusterBroker(); _duplicate.brokerId = brokerId; _duplicate.host = host; _duplicate.port = port; if (rack == null) { _duplicate.rack = null; } else { _duplicate.rack = rack; } return _duplicate; } @Override public String toString() { return "DescribeClusterBroker(" + "brokerId=" + brokerId + ", host=" + ((host == null) ? "null" : "'" + host.toString() + "'") + ", port=" + port + ", rack=" + ((rack == null) ? "null" : "'" + rack.toString() + "'") + ")"; } public int brokerId() { return this.brokerId; } public String host() { return this.host; } public int port() { return this.port; } public String rack() { return this.rack; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeClusterBroker setBrokerId(int v) { this.brokerId = v; return this; } public DescribeClusterBroker setHost(String v) { this.host = v; return this; } public DescribeClusterBroker setPort(int v) { this.port = v; return this; } public DescribeClusterBroker setRack(String v) { this.rack = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class DescribeClusterBrokerCollection extends ImplicitLinkedHashMultiCollection<DescribeClusterBroker> { public DescribeClusterBrokerCollection() { super(); } public DescribeClusterBrokerCollection(int expectedNumElements) { super(expectedNumElements); } public DescribeClusterBrokerCollection(Iterator<DescribeClusterBroker> iterator) { super(iterator); } public DescribeClusterBroker find(int brokerId) { DescribeClusterBroker _key = new DescribeClusterBroker(); _key.setBrokerId(brokerId); return find(_key); } public List<DescribeClusterBroker> findAll(int brokerId) { DescribeClusterBroker _key = new DescribeClusterBroker(); _key.setBrokerId(brokerId); return findAll(_key); } public DescribeClusterBrokerCollection duplicate() { DescribeClusterBrokerCollection _duplicate = new DescribeClusterBrokerCollection(size()); for (DescribeClusterBroker _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeClusterResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeClusterResponseData.*; public class DescribeClusterResponseDataJsonConverter { public static DescribeClusterResponseData read(JsonNode _node, short _version) { DescribeClusterResponseData _object = new DescribeClusterResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeClusterResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeClusterResponseData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeClusterResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeClusterResponseData"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("DescribeClusterResponseData: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DescribeClusterResponseData expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _clusterIdNode = _node.get("clusterId"); if (_clusterIdNode == null) { throw new RuntimeException("DescribeClusterResponseData: unable to locate field 'clusterId', which is mandatory in version " + _version); } else { if (!_clusterIdNode.isTextual()) { throw new RuntimeException("DescribeClusterResponseData expected a string type, but got " + _node.getNodeType()); } _object.clusterId = _clusterIdNode.asText(); } JsonNode _controllerIdNode = _node.get("controllerId"); if (_controllerIdNode == null) { throw new RuntimeException("DescribeClusterResponseData: unable to locate field 'controllerId', which is mandatory in version " + _version); } else { _object.controllerId = MessageUtil.jsonNodeToInt(_controllerIdNode, "DescribeClusterResponseData"); } JsonNode _brokersNode = _node.get("brokers"); if (_brokersNode == null) { throw new RuntimeException("DescribeClusterResponseData: unable to locate field 'brokers', which is mandatory in version " + _version); } else { if (!_brokersNode.isArray()) { throw new RuntimeException("DescribeClusterResponseData expected a JSON array, but got " + _node.getNodeType()); } DescribeClusterBrokerCollection _collection = new DescribeClusterBrokerCollection(_brokersNode.size()); _object.brokers = _collection; for (JsonNode _element : _brokersNode) { _collection.add(DescribeClusterBrokerJsonConverter.read(_element, _version)); } } JsonNode _clusterAuthorizedOperationsNode = _node.get("clusterAuthorizedOperations"); if (_clusterAuthorizedOperationsNode == null) { throw new RuntimeException("DescribeClusterResponseData: unable to locate field 'clusterAuthorizedOperations', which is mandatory in version " + _version); } else { _object.clusterAuthorizedOperations = MessageUtil.jsonNodeToInt(_clusterAuthorizedOperationsNode, "DescribeClusterResponseData"); } return _object; } public static JsonNode write(DescribeClusterResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } _node.set("clusterId", new TextNode(_object.clusterId)); _node.set("controllerId", new IntNode(_object.controllerId)); ArrayNode _brokersArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeClusterBroker _element : _object.brokers) { _brokersArray.add(DescribeClusterBrokerJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("brokers", _brokersArray); _node.set("clusterAuthorizedOperations", new IntNode(_object.clusterAuthorizedOperations)); return _node; } public static JsonNode write(DescribeClusterResponseData _object, short _version) { return write(_object, _version, true); } public static class DescribeClusterBrokerJsonConverter { public static DescribeClusterBroker read(JsonNode _node, short _version) { DescribeClusterBroker _object = new DescribeClusterBroker(); JsonNode _brokerIdNode = _node.get("brokerId"); if (_brokerIdNode == null) { throw new RuntimeException("DescribeClusterBroker: unable to locate field 'brokerId', which is mandatory in version " + _version); } else { _object.brokerId = MessageUtil.jsonNodeToInt(_brokerIdNode, "DescribeClusterBroker"); } JsonNode _hostNode = _node.get("host"); if (_hostNode == null) { throw new RuntimeException("DescribeClusterBroker: unable to locate field 'host', which is mandatory in version " + _version); } else { if (!_hostNode.isTextual()) { throw new RuntimeException("DescribeClusterBroker expected a string type, but got " + _node.getNodeType()); } _object.host = _hostNode.asText(); } JsonNode _portNode = _node.get("port"); if (_portNode == null) { throw new RuntimeException("DescribeClusterBroker: unable to locate field 'port', which is mandatory in version " + _version); } else { _object.port = MessageUtil.jsonNodeToInt(_portNode, "DescribeClusterBroker"); } JsonNode _rackNode = _node.get("rack"); if (_rackNode == null) { throw new RuntimeException("DescribeClusterBroker: unable to locate field 'rack', which is mandatory in version " + _version); } else { if (_rackNode.isNull()) { _object.rack = null; } else { if (!_rackNode.isTextual()) { throw new RuntimeException("DescribeClusterBroker expected a string type, but got " + _node.getNodeType()); } _object.rack = _rackNode.asText(); } } return _object; } public static JsonNode write(DescribeClusterBroker _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("brokerId", new IntNode(_object.brokerId)); _node.set("host", new TextNode(_object.host)); _node.set("port", new IntNode(_object.port)); if (_object.rack == null) { _node.set("rack", NullNode.instance); } else { _node.set("rack", new TextNode(_object.rack)); } return _node; } public static JsonNode write(DescribeClusterBroker _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeConfigsRequestData.java
/* * 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 DescribeConfigsRequestData implements ApiMessage { List<DescribeConfigsResource> resources; boolean includeSynonyms; boolean includeDocumentation; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("resources", new ArrayOf(DescribeConfigsResource.SCHEMA_0), "The resources whose configurations we want to describe.") ); public static final Schema SCHEMA_1 = new Schema( new Field("resources", new ArrayOf(DescribeConfigsResource.SCHEMA_0), "The resources whose configurations we want to describe."), new Field("include_synonyms", Type.BOOLEAN, "True if we should include all synonyms.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = new Schema( new Field("resources", new ArrayOf(DescribeConfigsResource.SCHEMA_0), "The resources whose configurations we want to describe."), new Field("include_synonyms", Type.BOOLEAN, "True if we should include all synonyms."), new Field("include_documentation", Type.BOOLEAN, "True if we should include configuration documentation.") ); public static final Schema SCHEMA_4 = new Schema( new Field("resources", new CompactArrayOf(DescribeConfigsResource.SCHEMA_4), "The resources whose configurations we want to describe."), new Field("include_synonyms", Type.BOOLEAN, "True if we should include all synonyms."), new Field("include_documentation", Type.BOOLEAN, "True if we should include configuration documentation."), TaggedFieldsSection.of( ) ); 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 DescribeConfigsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeConfigsRequestData() { this.resources = new ArrayList<DescribeConfigsResource>(0); this.includeSynonyms = false; this.includeDocumentation = false; } @Override public short apiKey() { return 32; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 4; } @Override public void read(Readable _readable, short _version) { { if (_version >= 4) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field resources 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<DescribeConfigsResource> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeConfigsResource(_readable, _version)); } this.resources = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field resources 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<DescribeConfigsResource> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeConfigsResource(_readable, _version)); } this.resources = newCollection; } } } if (_version >= 1) { this.includeSynonyms = _readable.readByte() != 0; } else { this.includeSynonyms = false; } if (_version >= 3) { this.includeDocumentation = _readable.readByte() != 0; } else { this.includeDocumentation = false; } this._unknownTaggedFields = null; if (_version >= 4) { 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; if (_version >= 4) { _writable.writeUnsignedVarint(resources.size() + 1); for (DescribeConfigsResource resourcesElement : resources) { resourcesElement.write(_writable, _cache, _version); } } else { _writable.writeInt(resources.size()); for (DescribeConfigsResource resourcesElement : resources) { resourcesElement.write(_writable, _cache, _version); } } if (_version >= 1) { _writable.writeByte(includeSynonyms ? (byte) 1 : (byte) 0); } else { if (this.includeSynonyms) { throw new UnsupportedVersionException("Attempted to write a non-default includeSynonyms at version " + _version); } } if (_version >= 3) { _writable.writeByte(includeDocumentation ? (byte) 1 : (byte) 0); } else { if (this.includeDocumentation) { throw new UnsupportedVersionException("Attempted to write a non-default includeDocumentation at version " + _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(resources.size() + 1)); } else { _size.addBytes(4); } for (DescribeConfigsResource resourcesElement : resources) { resourcesElement.addSize(_size, _cache, _version); } } if (_version >= 1) { _size.addBytes(1); } if (_version >= 3) { _size.addBytes(1); } 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 >= 4) { _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 DescribeConfigsRequestData)) return false; DescribeConfigsRequestData other = (DescribeConfigsRequestData) obj; if (this.resources == null) { if (other.resources != null) return false; } else { if (!this.resources.equals(other.resources)) return false; } if (includeSynonyms != other.includeSynonyms) return false; if (includeDocumentation != other.includeDocumentation) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (resources == null ? 0 : resources.hashCode()); hashCode = 31 * hashCode + (includeSynonyms ? 1231 : 1237); hashCode = 31 * hashCode + (includeDocumentation ? 1231 : 1237); return hashCode; } @Override public DescribeConfigsRequestData duplicate() { DescribeConfigsRequestData _duplicate = new DescribeConfigsRequestData(); ArrayList<DescribeConfigsResource> newResources = new ArrayList<DescribeConfigsResource>(resources.size()); for (DescribeConfigsResource _element : resources) { newResources.add(_element.duplicate()); } _duplicate.resources = newResources; _duplicate.includeSynonyms = includeSynonyms; _duplicate.includeDocumentation = includeDocumentation; return _duplicate; } @Override public String toString() { return "DescribeConfigsRequestData(" + "resources=" + MessageUtil.deepToString(resources.iterator()) + ", includeSynonyms=" + (includeSynonyms ? "true" : "false") + ", includeDocumentation=" + (includeDocumentation ? "true" : "false") + ")"; } public List<DescribeConfigsResource> resources() { return this.resources; } public boolean includeSynonyms() { return this.includeSynonyms; } public boolean includeDocumentation() { return this.includeDocumentation; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeConfigsRequestData setResources(List<DescribeConfigsResource> v) { this.resources = v; return this; } public DescribeConfigsRequestData setIncludeSynonyms(boolean v) { this.includeSynonyms = v; return this; } public DescribeConfigsRequestData setIncludeDocumentation(boolean v) { this.includeDocumentation = v; return this; } public static class DescribeConfigsResource implements Message { byte resourceType; String resourceName; List<String> configurationKeys; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.STRING, "The resource name."), new Field("configuration_keys", ArrayOf.nullable(Type.STRING), "The configuration keys to list, or null to list all configuration keys.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = new Schema( new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.COMPACT_STRING, "The resource name."), new Field("configuration_keys", CompactArrayOf.nullable(Type.COMPACT_STRING), "The configuration keys to list, or null to list all configuration keys."), TaggedFieldsSection.of( ) ); 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 DescribeConfigsResource(Readable _readable, short _version) { read(_readable, _version); } public DescribeConfigsResource() { this.resourceType = (byte) 0; this.resourceName = ""; this.configurationKeys = new ArrayList<String>(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 DescribeConfigsResource"); } this.resourceType = _readable.readByte(); { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field resourceName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field resourceName had invalid length " + length); } else { this.resourceName = _readable.readString(length); } } { if (_version >= 4) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.configurationKeys = 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field configurationKeys element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field configurationKeys element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.configurationKeys = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { this.configurationKeys = 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readShort(); if (length < 0) { throw new RuntimeException("non-nullable field configurationKeys element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field configurationKeys element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.configurationKeys = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 4) { 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.writeByte(resourceType); { byte[] _stringBytes = _cache.getSerializedValue(resourceName); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 4) { if (configurationKeys == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(configurationKeys.size() + 1); for (String configurationKeysElement : configurationKeys) { { byte[] _stringBytes = _cache.getSerializedValue(configurationKeysElement); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } } } else { if (configurationKeys == null) { _writable.writeInt(-1); } else { _writable.writeInt(configurationKeys.size()); for (String configurationKeysElement : configurationKeys) { { byte[] _stringBytes = _cache.getSerializedValue(configurationKeysElement); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } } } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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 DescribeConfigsResource"); } _size.addBytes(1); { byte[] _stringBytes = resourceName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'resourceName' field is too long to be serialized"); } _cache.cacheSerializedValue(resourceName, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (configurationKeys == null) { if (_version >= 4) { _size.addBytes(1); } else { _size.addBytes(4); } } else { if (_version >= 4) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(configurationKeys.size() + 1)); } else { _size.addBytes(4); } for (String configurationKeysElement : configurationKeys) { byte[] _stringBytes = configurationKeysElement.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'configurationKeysElement' field is too long to be serialized"); } _cache.cacheSerializedValue(configurationKeysElement, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 >= 4) { _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 DescribeConfigsResource)) return false; DescribeConfigsResource other = (DescribeConfigsResource) obj; if (resourceType != other.resourceType) return false; if (this.resourceName == null) { if (other.resourceName != null) return false; } else { if (!this.resourceName.equals(other.resourceName)) return false; } if (this.configurationKeys == null) { if (other.configurationKeys != null) return false; } else { if (!this.configurationKeys.equals(other.configurationKeys)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + resourceType; hashCode = 31 * hashCode + (resourceName == null ? 0 : resourceName.hashCode()); hashCode = 31 * hashCode + (configurationKeys == null ? 0 : configurationKeys.hashCode()); return hashCode; } @Override public DescribeConfigsResource duplicate() { DescribeConfigsResource _duplicate = new DescribeConfigsResource(); _duplicate.resourceType = resourceType; _duplicate.resourceName = resourceName; if (configurationKeys == null) { _duplicate.configurationKeys = null; } else { ArrayList<String> newConfigurationKeys = new ArrayList<String>(configurationKeys.size()); for (String _element : configurationKeys) { newConfigurationKeys.add(_element); } _duplicate.configurationKeys = newConfigurationKeys; } return _duplicate; } @Override public String toString() { return "DescribeConfigsResource(" + "resourceType=" + resourceType + ", resourceName=" + ((resourceName == null) ? "null" : "'" + resourceName.toString() + "'") + ", configurationKeys=" + ((configurationKeys == null) ? "null" : MessageUtil.deepToString(configurationKeys.iterator())) + ")"; } public byte resourceType() { return this.resourceType; } public String resourceName() { return this.resourceName; } public List<String> configurationKeys() { return this.configurationKeys; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeConfigsResource setResourceType(byte v) { this.resourceType = v; return this; } public DescribeConfigsResource setResourceName(String v) { this.resourceName = v; return this; } public DescribeConfigsResource setConfigurationKeys(List<String> v) { this.configurationKeys = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeConfigsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeConfigsRequestData.*; public class DescribeConfigsRequestDataJsonConverter { public static DescribeConfigsRequestData read(JsonNode _node, short _version) { DescribeConfigsRequestData _object = new DescribeConfigsRequestData(); JsonNode _resourcesNode = _node.get("resources"); if (_resourcesNode == null) { throw new RuntimeException("DescribeConfigsRequestData: unable to locate field 'resources', which is mandatory in version " + _version); } else { if (!_resourcesNode.isArray()) { throw new RuntimeException("DescribeConfigsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeConfigsResource> _collection = new ArrayList<DescribeConfigsResource>(_resourcesNode.size()); _object.resources = _collection; for (JsonNode _element : _resourcesNode) { _collection.add(DescribeConfigsResourceJsonConverter.read(_element, _version)); } } JsonNode _includeSynonymsNode = _node.get("includeSynonyms"); if (_includeSynonymsNode == null) { if (_version >= 1) { throw new RuntimeException("DescribeConfigsRequestData: unable to locate field 'includeSynonyms', which is mandatory in version " + _version); } else { _object.includeSynonyms = false; } } else { if (!_includeSynonymsNode.isBoolean()) { throw new RuntimeException("DescribeConfigsRequestData expected Boolean type, but got " + _node.getNodeType()); } _object.includeSynonyms = _includeSynonymsNode.asBoolean(); } JsonNode _includeDocumentationNode = _node.get("includeDocumentation"); if (_includeDocumentationNode == null) { if (_version >= 3) { throw new RuntimeException("DescribeConfigsRequestData: unable to locate field 'includeDocumentation', which is mandatory in version " + _version); } else { _object.includeDocumentation = false; } } else { if (!_includeDocumentationNode.isBoolean()) { throw new RuntimeException("DescribeConfigsRequestData expected Boolean type, but got " + _node.getNodeType()); } _object.includeDocumentation = _includeDocumentationNode.asBoolean(); } return _object; } public static JsonNode write(DescribeConfigsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _resourcesArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeConfigsResource _element : _object.resources) { _resourcesArray.add(DescribeConfigsResourceJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("resources", _resourcesArray); if (_version >= 1) { _node.set("includeSynonyms", BooleanNode.valueOf(_object.includeSynonyms)); } else { if (_object.includeSynonyms) { throw new UnsupportedVersionException("Attempted to write a non-default includeSynonyms at version " + _version); } } if (_version >= 3) { _node.set("includeDocumentation", BooleanNode.valueOf(_object.includeDocumentation)); } else { if (_object.includeDocumentation) { throw new UnsupportedVersionException("Attempted to write a non-default includeDocumentation at version " + _version); } } return _node; } public static JsonNode write(DescribeConfigsRequestData _object, short _version) { return write(_object, _version, true); } public static class DescribeConfigsResourceJsonConverter { public static DescribeConfigsResource read(JsonNode _node, short _version) { DescribeConfigsResource _object = new DescribeConfigsResource(); JsonNode _resourceTypeNode = _node.get("resourceType"); if (_resourceTypeNode == null) { throw new RuntimeException("DescribeConfigsResource: unable to locate field 'resourceType', which is mandatory in version " + _version); } else { _object.resourceType = MessageUtil.jsonNodeToByte(_resourceTypeNode, "DescribeConfigsResource"); } JsonNode _resourceNameNode = _node.get("resourceName"); if (_resourceNameNode == null) { throw new RuntimeException("DescribeConfigsResource: unable to locate field 'resourceName', which is mandatory in version " + _version); } else { if (!_resourceNameNode.isTextual()) { throw new RuntimeException("DescribeConfigsResource expected a string type, but got " + _node.getNodeType()); } _object.resourceName = _resourceNameNode.asText(); } JsonNode _configurationKeysNode = _node.get("configurationKeys"); if (_configurationKeysNode == null) { throw new RuntimeException("DescribeConfigsResource: unable to locate field 'configurationKeys', which is mandatory in version " + _version); } else { if (_configurationKeysNode.isNull()) { _object.configurationKeys = null; } else { if (!_configurationKeysNode.isArray()) { throw new RuntimeException("DescribeConfigsResource expected a JSON array, but got " + _node.getNodeType()); } ArrayList<String> _collection = new ArrayList<String>(_configurationKeysNode.size()); _object.configurationKeys = _collection; for (JsonNode _element : _configurationKeysNode) { if (!_element.isTextual()) { throw new RuntimeException("DescribeConfigsResource element expected a string type, but got " + _node.getNodeType()); } _collection.add(_element.asText()); } } } return _object; } public static JsonNode write(DescribeConfigsResource _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("resourceType", new ShortNode(_object.resourceType)); _node.set("resourceName", new TextNode(_object.resourceName)); if (_object.configurationKeys == null) { _node.set("configurationKeys", NullNode.instance); } else { ArrayNode _configurationKeysArray = new ArrayNode(JsonNodeFactory.instance); for (String _element : _object.configurationKeys) { _configurationKeysArray.add(new TextNode(_element)); } _node.set("configurationKeys", _configurationKeysArray); } return _node; } public static JsonNode write(DescribeConfigsResource _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeConfigsResponseData.java
/* * 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 DescribeConfigsResponseData implements ApiMessage { int throttleTimeMs; List<DescribeConfigsResult> results; private List<RawTaggedField> _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("results", new ArrayOf(DescribeConfigsResult.SCHEMA_0), "The results for each resource.") ); public static final Schema SCHEMA_1 = 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("results", new ArrayOf(DescribeConfigsResult.SCHEMA_1), "The results for each resource.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = 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("results", new ArrayOf(DescribeConfigsResult.SCHEMA_3), "The results for each resource.") ); public static final Schema SCHEMA_4 = 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("results", new CompactArrayOf(DescribeConfigsResult.SCHEMA_4), "The results for each resource."), TaggedFieldsSection.of( ) ); 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 DescribeConfigsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeConfigsResponseData() { this.throttleTimeMs = 0; this.results = new ArrayList<DescribeConfigsResult>(0); } @Override public short apiKey() { return 32; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 4; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); { if (_version >= 4) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<DescribeConfigsResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeConfigsResult(_readable, _version)); } this.results = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<DescribeConfigsResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeConfigsResult(_readable, _version)); } this.results = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 4) { 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); if (_version >= 4) { _writable.writeUnsignedVarint(results.size() + 1); for (DescribeConfigsResult resultsElement : results) { resultsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(results.size()); for (DescribeConfigsResult resultsElement : results) { resultsElement.write(_writable, _cache, _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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(4); { if (_version >= 4) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(results.size() + 1)); } else { _size.addBytes(4); } for (DescribeConfigsResult resultsElement : results) { resultsElement.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 >= 4) { _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 DescribeConfigsResponseData)) return false; DescribeConfigsResponseData other = (DescribeConfigsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.results == null) { if (other.results != null) return false; } else { if (!this.results.equals(other.results)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (results == null ? 0 : results.hashCode()); return hashCode; } @Override public DescribeConfigsResponseData duplicate() { DescribeConfigsResponseData _duplicate = new DescribeConfigsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; ArrayList<DescribeConfigsResult> newResults = new ArrayList<DescribeConfigsResult>(results.size()); for (DescribeConfigsResult _element : results) { newResults.add(_element.duplicate()); } _duplicate.results = newResults; return _duplicate; } @Override public String toString() { return "DescribeConfigsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", results=" + MessageUtil.deepToString(results.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public List<DescribeConfigsResult> results() { return this.results; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeConfigsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeConfigsResponseData setResults(List<DescribeConfigsResult> v) { this.results = v; return this; } public static class DescribeConfigsResult implements Message { short errorCode; String errorMessage; byte resourceType; String resourceName; List<DescribeConfigsResourceResult> configs; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if we were able to successfully describe the configurations."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or null if we were able to successfully describe the configurations."), new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.STRING, "The resource name."), new Field("configs", new ArrayOf(DescribeConfigsResourceResult.SCHEMA_0), "Each listed configuration.") ); public static final Schema SCHEMA_1 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if we were able to successfully describe the configurations."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or null if we were able to successfully describe the configurations."), new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.STRING, "The resource name."), new Field("configs", new ArrayOf(DescribeConfigsResourceResult.SCHEMA_1), "Each listed configuration.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if we were able to successfully describe the configurations."), new Field("error_message", Type.NULLABLE_STRING, "The error message, or null if we were able to successfully describe the configurations."), new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.STRING, "The resource name."), new Field("configs", new ArrayOf(DescribeConfigsResourceResult.SCHEMA_3), "Each listed configuration.") ); public static final Schema SCHEMA_4 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if we were able to successfully describe the configurations."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The error message, or null if we were able to successfully describe the configurations."), new Field("resource_type", Type.INT8, "The resource type."), new Field("resource_name", Type.COMPACT_STRING, "The resource name."), new Field("configs", new CompactArrayOf(DescribeConfigsResourceResult.SCHEMA_4), "Each listed configuration."), TaggedFieldsSection.of( ) ); 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 DescribeConfigsResult(Readable _readable, short _version) { read(_readable, _version); } public DescribeConfigsResult() { this.errorCode = (short) 0; this.errorMessage = ""; this.resourceType = (byte) 0; this.resourceName = ""; this.configs = new ArrayList<DescribeConfigsResourceResult>(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 DescribeConfigsResult"); } this.errorCode = _readable.readShort(); { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } this.resourceType = _readable.readByte(); { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field resourceName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field resourceName had invalid length " + length); } else { this.resourceName = _readable.readString(length); } } { if (_version >= 4) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field configs 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<DescribeConfigsResourceResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeConfigsResourceResult(_readable, _version)); } this.configs = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field configs 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<DescribeConfigsResourceResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeConfigsResourceResult(_readable, _version)); } this.configs = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 4) { 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 (errorMessage == null) { if (_version >= 4) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(resourceType); { byte[] _stringBytes = _cache.getSerializedValue(resourceName); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 4) { _writable.writeUnsignedVarint(configs.size() + 1); for (DescribeConfigsResourceResult configsElement : configs) { configsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(configs.size()); for (DescribeConfigsResourceResult configsElement : configs) { configsElement.write(_writable, _cache, _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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 DescribeConfigsResult"); } _size.addBytes(2); if (errorMessage == null) { if (_version >= 4) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); { byte[] _stringBytes = resourceName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'resourceName' field is too long to be serialized"); } _cache.cacheSerializedValue(resourceName, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 4) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(configs.size() + 1)); } else { _size.addBytes(4); } for (DescribeConfigsResourceResult configsElement : configs) { configsElement.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 >= 4) { _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 DescribeConfigsResult)) return false; DescribeConfigsResult other = (DescribeConfigsResult) obj; 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 (resourceType != other.resourceType) return false; if (this.resourceName == null) { if (other.resourceName != null) return false; } else { if (!this.resourceName.equals(other.resourceName)) return false; } if (this.configs == null) { if (other.configs != null) return false; } else { if (!this.configs.equals(other.configs)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode()); hashCode = 31 * hashCode + resourceType; hashCode = 31 * hashCode + (resourceName == null ? 0 : resourceName.hashCode()); hashCode = 31 * hashCode + (configs == null ? 0 : configs.hashCode()); return hashCode; } @Override public DescribeConfigsResult duplicate() { DescribeConfigsResult _duplicate = new DescribeConfigsResult(); _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } _duplicate.resourceType = resourceType; _duplicate.resourceName = resourceName; ArrayList<DescribeConfigsResourceResult> newConfigs = new ArrayList<DescribeConfigsResourceResult>(configs.size()); for (DescribeConfigsResourceResult _element : configs) { newConfigs.add(_element.duplicate()); } _duplicate.configs = newConfigs; return _duplicate; } @Override public String toString() { return "DescribeConfigsResult(" + "errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", resourceType=" + resourceType + ", resourceName=" + ((resourceName == null) ? "null" : "'" + resourceName.toString() + "'") + ", configs=" + MessageUtil.deepToString(configs.iterator()) + ")"; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public byte resourceType() { return this.resourceType; } public String resourceName() { return this.resourceName; } public List<DescribeConfigsResourceResult> configs() { return this.configs; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeConfigsResult setErrorCode(short v) { this.errorCode = v; return this; } public DescribeConfigsResult setErrorMessage(String v) { this.errorMessage = v; return this; } public DescribeConfigsResult setResourceType(byte v) { this.resourceType = v; return this; } public DescribeConfigsResult setResourceName(String v) { this.resourceName = v; return this; } public DescribeConfigsResult setConfigs(List<DescribeConfigsResourceResult> v) { this.configs = v; return this; } } public static class DescribeConfigsResourceResult implements Message { String name; String value; boolean readOnly; boolean isDefault; byte configSource; boolean isSensitive; List<DescribeConfigsSynonym> synonyms; byte configType; String documentation; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The configuration name."), new Field("value", Type.NULLABLE_STRING, "The configuration value."), new Field("read_only", Type.BOOLEAN, "True if the configuration is read-only."), new Field("is_default", Type.BOOLEAN, "True if the configuration is not set."), new Field("is_sensitive", Type.BOOLEAN, "True if this configuration is sensitive.") ); public static final Schema SCHEMA_1 = new Schema( new Field("name", Type.STRING, "The configuration name."), new Field("value", Type.NULLABLE_STRING, "The configuration value."), new Field("read_only", Type.BOOLEAN, "True if the configuration is read-only."), new Field("config_source", Type.INT8, "The configuration source."), new Field("is_sensitive", Type.BOOLEAN, "True if this configuration is sensitive."), new Field("synonyms", new ArrayOf(DescribeConfigsSynonym.SCHEMA_1), "The synonyms for this configuration key.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = new Schema( new Field("name", Type.STRING, "The configuration name."), new Field("value", Type.NULLABLE_STRING, "The configuration value."), new Field("read_only", Type.BOOLEAN, "True if the configuration is read-only."), new Field("config_source", Type.INT8, "The configuration source."), new Field("is_sensitive", Type.BOOLEAN, "True if this configuration is sensitive."), new Field("synonyms", new ArrayOf(DescribeConfigsSynonym.SCHEMA_1), "The synonyms for this configuration key."), new Field("config_type", Type.INT8, "The configuration data type. Type can be one of the following values - BOOLEAN, STRING, INT, SHORT, LONG, DOUBLE, LIST, CLASS, PASSWORD"), new Field("documentation", Type.NULLABLE_STRING, "The configuration documentation.") ); public static final Schema SCHEMA_4 = new Schema( new Field("name", Type.COMPACT_STRING, "The configuration name."), new Field("value", Type.COMPACT_NULLABLE_STRING, "The configuration value."), new Field("read_only", Type.BOOLEAN, "True if the configuration is read-only."), new Field("config_source", Type.INT8, "The configuration source."), new Field("is_sensitive", Type.BOOLEAN, "True if this configuration is sensitive."), new Field("synonyms", new CompactArrayOf(DescribeConfigsSynonym.SCHEMA_4), "The synonyms for this configuration key."), new Field("config_type", Type.INT8, "The configuration data type. Type can be one of the following values - BOOLEAN, STRING, INT, SHORT, LONG, DOUBLE, LIST, CLASS, PASSWORD"), new Field("documentation", Type.COMPACT_NULLABLE_STRING, "The configuration documentation."), TaggedFieldsSection.of( ) ); 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 DescribeConfigsResourceResult(Readable _readable, short _version) { read(_readable, _version); } public DescribeConfigsResourceResult() { this.name = ""; this.value = ""; this.readOnly = false; this.isDefault = false; this.configSource = (byte) -1; this.isSensitive = false; this.synonyms = new ArrayList<DescribeConfigsSynonym>(0); this.configType = (byte) 0; this.documentation = ""; } @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 DescribeConfigsResourceResult"); } { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.value = null; } else if (length > 0x7fff) { throw new RuntimeException("string field value had invalid length " + length); } else { this.value = _readable.readString(length); } } this.readOnly = _readable.readByte() != 0; if (_version <= 0) { this.isDefault = _readable.readByte() != 0; } else { this.isDefault = false; } if (_version >= 1) { this.configSource = _readable.readByte(); } else { this.configSource = (byte) -1; } this.isSensitive = _readable.readByte() != 0; if (_version >= 1) { if (_version >= 4) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field synonyms 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<DescribeConfigsSynonym> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeConfigsSynonym(_readable, _version)); } this.synonyms = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field synonyms 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<DescribeConfigsSynonym> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeConfigsSynonym(_readable, _version)); } this.synonyms = newCollection; } } } else { this.synonyms = new ArrayList<DescribeConfigsSynonym>(0); } if (_version >= 3) { this.configType = _readable.readByte(); } else { this.configType = (byte) 0; } if (_version >= 3) { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.documentation = null; } else if (length > 0x7fff) { throw new RuntimeException("string field documentation had invalid length " + length); } else { this.documentation = _readable.readString(length); } } else { this.documentation = ""; } this._unknownTaggedFields = null; if (_version >= 4) { 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(name); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (value == null) { if (_version >= 4) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(value); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(readOnly ? (byte) 1 : (byte) 0); if (_version <= 0) { _writable.writeByte(isDefault ? (byte) 1 : (byte) 0); } else { if (this.isDefault) { throw new UnsupportedVersionException("Attempted to write a non-default isDefault at version " + _version); } } if (_version >= 1) { _writable.writeByte(configSource); } _writable.writeByte(isSensitive ? (byte) 1 : (byte) 0); if (_version >= 1) { if (_version >= 4) { _writable.writeUnsignedVarint(synonyms.size() + 1); for (DescribeConfigsSynonym synonymsElement : synonyms) { synonymsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(synonyms.size()); for (DescribeConfigsSynonym synonymsElement : synonyms) { synonymsElement.write(_writable, _cache, _version); } } } if (_version >= 3) { _writable.writeByte(configType); } if (_version >= 3) { if (documentation == null) { if (_version >= 4) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(documentation); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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 DescribeConfigsResourceResult"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (value == null) { if (_version >= 4) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = value.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'value' field is too long to be serialized"); } _cache.cacheSerializedValue(value, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); if (_version <= 0) { _size.addBytes(1); } if (_version >= 1) { _size.addBytes(1); } _size.addBytes(1); if (_version >= 1) { { if (_version >= 4) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(synonyms.size() + 1)); } else { _size.addBytes(4); } for (DescribeConfigsSynonym synonymsElement : synonyms) { synonymsElement.addSize(_size, _cache, _version); } } } if (_version >= 3) { _size.addBytes(1); } if (_version >= 3) { if (documentation == null) { if (_version >= 4) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = documentation.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'documentation' field is too long to be serialized"); } _cache.cacheSerializedValue(documentation, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 >= 4) { _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 DescribeConfigsResourceResult)) return false; DescribeConfigsResourceResult other = (DescribeConfigsResourceResult) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (this.value == null) { if (other.value != null) return false; } else { if (!this.value.equals(other.value)) return false; } if (readOnly != other.readOnly) return false; if (isDefault != other.isDefault) return false; if (configSource != other.configSource) return false; if (isSensitive != other.isSensitive) return false; if (this.synonyms == null) { if (other.synonyms != null) return false; } else { if (!this.synonyms.equals(other.synonyms)) return false; } if (configType != other.configType) return false; if (this.documentation == null) { if (other.documentation != null) return false; } else { if (!this.documentation.equals(other.documentation)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + (value == null ? 0 : value.hashCode()); hashCode = 31 * hashCode + (readOnly ? 1231 : 1237); hashCode = 31 * hashCode + (isDefault ? 1231 : 1237); hashCode = 31 * hashCode + configSource; hashCode = 31 * hashCode + (isSensitive ? 1231 : 1237); hashCode = 31 * hashCode + (synonyms == null ? 0 : synonyms.hashCode()); hashCode = 31 * hashCode + configType; hashCode = 31 * hashCode + (documentation == null ? 0 : documentation.hashCode()); return hashCode; } @Override public DescribeConfigsResourceResult duplicate() { DescribeConfigsResourceResult _duplicate = new DescribeConfigsResourceResult(); _duplicate.name = name; if (value == null) { _duplicate.value = null; } else { _duplicate.value = value; } _duplicate.readOnly = readOnly; _duplicate.isDefault = isDefault; _duplicate.configSource = configSource; _duplicate.isSensitive = isSensitive; ArrayList<DescribeConfigsSynonym> newSynonyms = new ArrayList<DescribeConfigsSynonym>(synonyms.size()); for (DescribeConfigsSynonym _element : synonyms) { newSynonyms.add(_element.duplicate()); } _duplicate.synonyms = newSynonyms; _duplicate.configType = configType; if (documentation == null) { _duplicate.documentation = null; } else { _duplicate.documentation = documentation; } return _duplicate; } @Override public String toString() { return "DescribeConfigsResourceResult(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", value=" + ((value == null) ? "null" : "'" + value.toString() + "'") + ", readOnly=" + (readOnly ? "true" : "false") + ", isDefault=" + (isDefault ? "true" : "false") + ", configSource=" + configSource + ", isSensitive=" + (isSensitive ? "true" : "false") + ", synonyms=" + MessageUtil.deepToString(synonyms.iterator()) + ", configType=" + configType + ", documentation=" + ((documentation == null) ? "null" : "'" + documentation.toString() + "'") + ")"; } public String name() { return this.name; } public String value() { return this.value; } public boolean readOnly() { return this.readOnly; } public boolean isDefault() { return this.isDefault; } public byte configSource() { return this.configSource; } public boolean isSensitive() { return this.isSensitive; } public List<DescribeConfigsSynonym> synonyms() { return this.synonyms; } public byte configType() { return this.configType; } public String documentation() { return this.documentation; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeConfigsResourceResult setName(String v) { this.name = v; return this; } public DescribeConfigsResourceResult setValue(String v) { this.value = v; return this; } public DescribeConfigsResourceResult setReadOnly(boolean v) { this.readOnly = v; return this; } public DescribeConfigsResourceResult setIsDefault(boolean v) { this.isDefault = v; return this; } public DescribeConfigsResourceResult setConfigSource(byte v) { this.configSource = v; return this; } public DescribeConfigsResourceResult setIsSensitive(boolean v) { this.isSensitive = v; return this; } public DescribeConfigsResourceResult setSynonyms(List<DescribeConfigsSynonym> v) { this.synonyms = v; return this; } public DescribeConfigsResourceResult setConfigType(byte v) { this.configType = v; return this; } public DescribeConfigsResourceResult setDocumentation(String v) { this.documentation = v; return this; } } public static class DescribeConfigsSynonym implements Message { String name; String value; byte source; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_1 = new Schema( new Field("name", Type.STRING, "The synonym name."), new Field("value", Type.NULLABLE_STRING, "The synonym value."), new Field("source", Type.INT8, "The synonym source.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = new Schema( new Field("name", Type.COMPACT_STRING, "The synonym name."), new Field("value", Type.COMPACT_NULLABLE_STRING, "The synonym value."), new Field("source", Type.INT8, "The synonym source."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { null, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4 }; public static final short LOWEST_SUPPORTED_VERSION = 1; public static final short HIGHEST_SUPPORTED_VERSION = 4; public DescribeConfigsSynonym(Readable _readable, short _version) { read(_readable, _version); } public DescribeConfigsSynonym() { this.name = ""; this.value = ""; this.source = (byte) 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 DescribeConfigsSynonym"); } { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { int length; if (_version >= 4) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.value = null; } else if (length > 0x7fff) { throw new RuntimeException("string field value had invalid length " + length); } else { this.value = _readable.readString(length); } } this.source = _readable.readByte(); this._unknownTaggedFields = null; if (_version >= 4) { 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) { if (_version < 1) { throw new UnsupportedVersionException("Can't write version " + _version + " of DescribeConfigsSynonym"); } int _numTaggedFields = 0; { byte[] _stringBytes = _cache.getSerializedValue(name); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (value == null) { if (_version >= 4) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(value); if (_version >= 4) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } _writable.writeByte(source); RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 4) { _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 DescribeConfigsSynonym"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (value == null) { if (_version >= 4) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = value.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'value' field is too long to be serialized"); } _cache.cacheSerializedValue(value, _stringBytes); if (_version >= 4) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } _size.addBytes(1); 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 >= 4) { _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 DescribeConfigsSynonym)) return false; DescribeConfigsSynonym other = (DescribeConfigsSynonym) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (this.value == null) { if (other.value != null) return false; } else { if (!this.value.equals(other.value)) return false; } if (source != other.source) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + (value == null ? 0 : value.hashCode()); hashCode = 31 * hashCode + source; return hashCode; } @Override public DescribeConfigsSynonym duplicate() { DescribeConfigsSynonym _duplicate = new DescribeConfigsSynonym(); _duplicate.name = name; if (value == null) { _duplicate.value = null; } else { _duplicate.value = value; } _duplicate.source = source; return _duplicate; } @Override public String toString() { return "DescribeConfigsSynonym(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", value=" + ((value == null) ? "null" : "'" + value.toString() + "'") + ", source=" + source + ")"; } public String name() { return this.name; } public String value() { return this.value; } public byte source() { return this.source; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeConfigsSynonym setName(String v) { this.name = v; return this; } public DescribeConfigsSynonym setValue(String v) { this.value = v; return this; } public DescribeConfigsSynonym setSource(byte v) { this.source = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeConfigsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeConfigsResponseData.*; public class DescribeConfigsResponseDataJsonConverter { public static DescribeConfigsResponseData read(JsonNode _node, short _version) { DescribeConfigsResponseData _object = new DescribeConfigsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeConfigsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeConfigsResponseData"); } JsonNode _resultsNode = _node.get("results"); if (_resultsNode == null) { throw new RuntimeException("DescribeConfigsResponseData: unable to locate field 'results', which is mandatory in version " + _version); } else { if (!_resultsNode.isArray()) { throw new RuntimeException("DescribeConfigsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeConfigsResult> _collection = new ArrayList<DescribeConfigsResult>(_resultsNode.size()); _object.results = _collection; for (JsonNode _element : _resultsNode) { _collection.add(DescribeConfigsResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeConfigsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); ArrayNode _resultsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeConfigsResult _element : _object.results) { _resultsArray.add(DescribeConfigsResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("results", _resultsArray); return _node; } public static JsonNode write(DescribeConfigsResponseData _object, short _version) { return write(_object, _version, true); } public static class DescribeConfigsResourceResultJsonConverter { public static DescribeConfigsResourceResult read(JsonNode _node, short _version) { DescribeConfigsResourceResult _object = new DescribeConfigsResourceResult(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("DescribeConfigsResourceResult expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _valueNode = _node.get("value"); if (_valueNode == null) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'value', which is mandatory in version " + _version); } else { if (_valueNode.isNull()) { _object.value = null; } else { if (!_valueNode.isTextual()) { throw new RuntimeException("DescribeConfigsResourceResult expected a string type, but got " + _node.getNodeType()); } _object.value = _valueNode.asText(); } } JsonNode _readOnlyNode = _node.get("readOnly"); if (_readOnlyNode == null) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'readOnly', which is mandatory in version " + _version); } else { if (!_readOnlyNode.isBoolean()) { throw new RuntimeException("DescribeConfigsResourceResult expected Boolean type, but got " + _node.getNodeType()); } _object.readOnly = _readOnlyNode.asBoolean(); } JsonNode _isDefaultNode = _node.get("isDefault"); if (_isDefaultNode == null) { if (_version <= 0) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'isDefault', which is mandatory in version " + _version); } else { _object.isDefault = false; } } else { if (!_isDefaultNode.isBoolean()) { throw new RuntimeException("DescribeConfigsResourceResult expected Boolean type, but got " + _node.getNodeType()); } _object.isDefault = _isDefaultNode.asBoolean(); } JsonNode _configSourceNode = _node.get("configSource"); if (_configSourceNode == null) { if (_version >= 1) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'configSource', which is mandatory in version " + _version); } else { _object.configSource = (byte) -1; } } else { _object.configSource = MessageUtil.jsonNodeToByte(_configSourceNode, "DescribeConfigsResourceResult"); } JsonNode _isSensitiveNode = _node.get("isSensitive"); if (_isSensitiveNode == null) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'isSensitive', which is mandatory in version " + _version); } else { if (!_isSensitiveNode.isBoolean()) { throw new RuntimeException("DescribeConfigsResourceResult expected Boolean type, but got " + _node.getNodeType()); } _object.isSensitive = _isSensitiveNode.asBoolean(); } JsonNode _synonymsNode = _node.get("synonyms"); if (_synonymsNode == null) { if (_version >= 1) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'synonyms', which is mandatory in version " + _version); } else { _object.synonyms = new ArrayList<DescribeConfigsSynonym>(0); } } else { if (!_synonymsNode.isArray()) { throw new RuntimeException("DescribeConfigsResourceResult expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeConfigsSynonym> _collection = new ArrayList<DescribeConfigsSynonym>(_synonymsNode.size()); _object.synonyms = _collection; for (JsonNode _element : _synonymsNode) { _collection.add(DescribeConfigsSynonymJsonConverter.read(_element, _version)); } } JsonNode _configTypeNode = _node.get("configType"); if (_configTypeNode == null) { if (_version >= 3) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'configType', which is mandatory in version " + _version); } else { _object.configType = (byte) 0; } } else { _object.configType = MessageUtil.jsonNodeToByte(_configTypeNode, "DescribeConfigsResourceResult"); } JsonNode _documentationNode = _node.get("documentation"); if (_documentationNode == null) { if (_version >= 3) { throw new RuntimeException("DescribeConfigsResourceResult: unable to locate field 'documentation', which is mandatory in version " + _version); } else { _object.documentation = ""; } } else { if (_documentationNode.isNull()) { _object.documentation = null; } else { if (!_documentationNode.isTextual()) { throw new RuntimeException("DescribeConfigsResourceResult expected a string type, but got " + _node.getNodeType()); } _object.documentation = _documentationNode.asText(); } } return _object; } public static JsonNode write(DescribeConfigsResourceResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); if (_object.value == null) { _node.set("value", NullNode.instance); } else { _node.set("value", new TextNode(_object.value)); } _node.set("readOnly", BooleanNode.valueOf(_object.readOnly)); if (_version <= 0) { _node.set("isDefault", BooleanNode.valueOf(_object.isDefault)); } else { if (_object.isDefault) { throw new UnsupportedVersionException("Attempted to write a non-default isDefault at version " + _version); } } if (_version >= 1) { _node.set("configSource", new ShortNode(_object.configSource)); } _node.set("isSensitive", BooleanNode.valueOf(_object.isSensitive)); if (_version >= 1) { ArrayNode _synonymsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeConfigsSynonym _element : _object.synonyms) { _synonymsArray.add(DescribeConfigsSynonymJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("synonyms", _synonymsArray); } if (_version >= 3) { _node.set("configType", new ShortNode(_object.configType)); } if (_version >= 3) { if (_object.documentation == null) { _node.set("documentation", NullNode.instance); } else { _node.set("documentation", new TextNode(_object.documentation)); } } return _node; } public static JsonNode write(DescribeConfigsResourceResult _object, short _version) { return write(_object, _version, true); } } public static class DescribeConfigsResultJsonConverter { public static DescribeConfigsResult read(JsonNode _node, short _version) { DescribeConfigsResult _object = new DescribeConfigsResult(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeConfigsResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeConfigsResult"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("DescribeConfigsResult: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DescribeConfigsResult expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _resourceTypeNode = _node.get("resourceType"); if (_resourceTypeNode == null) { throw new RuntimeException("DescribeConfigsResult: unable to locate field 'resourceType', which is mandatory in version " + _version); } else { _object.resourceType = MessageUtil.jsonNodeToByte(_resourceTypeNode, "DescribeConfigsResult"); } JsonNode _resourceNameNode = _node.get("resourceName"); if (_resourceNameNode == null) { throw new RuntimeException("DescribeConfigsResult: unable to locate field 'resourceName', which is mandatory in version " + _version); } else { if (!_resourceNameNode.isTextual()) { throw new RuntimeException("DescribeConfigsResult expected a string type, but got " + _node.getNodeType()); } _object.resourceName = _resourceNameNode.asText(); } JsonNode _configsNode = _node.get("configs"); if (_configsNode == null) { throw new RuntimeException("DescribeConfigsResult: unable to locate field 'configs', which is mandatory in version " + _version); } else { if (!_configsNode.isArray()) { throw new RuntimeException("DescribeConfigsResult expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeConfigsResourceResult> _collection = new ArrayList<DescribeConfigsResourceResult>(_configsNode.size()); _object.configs = _collection; for (JsonNode _element : _configsNode) { _collection.add(DescribeConfigsResourceResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeConfigsResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } _node.set("resourceType", new ShortNode(_object.resourceType)); _node.set("resourceName", new TextNode(_object.resourceName)); ArrayNode _configsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeConfigsResourceResult _element : _object.configs) { _configsArray.add(DescribeConfigsResourceResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("configs", _configsArray); return _node; } public static JsonNode write(DescribeConfigsResult _object, short _version) { return write(_object, _version, true); } } public static class DescribeConfigsSynonymJsonConverter { public static DescribeConfigsSynonym read(JsonNode _node, short _version) { DescribeConfigsSynonym _object = new DescribeConfigsSynonym(); if (_version < 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribeConfigsSynonym"); } JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("DescribeConfigsSynonym: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("DescribeConfigsSynonym expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _valueNode = _node.get("value"); if (_valueNode == null) { throw new RuntimeException("DescribeConfigsSynonym: unable to locate field 'value', which is mandatory in version " + _version); } else { if (_valueNode.isNull()) { _object.value = null; } else { if (!_valueNode.isTextual()) { throw new RuntimeException("DescribeConfigsSynonym expected a string type, but got " + _node.getNodeType()); } _object.value = _valueNode.asText(); } } JsonNode _sourceNode = _node.get("source"); if (_sourceNode == null) { throw new RuntimeException("DescribeConfigsSynonym: unable to locate field 'source', which is mandatory in version " + _version); } else { _object.source = MessageUtil.jsonNodeToByte(_sourceNode, "DescribeConfigsSynonym"); } return _object; } public static JsonNode write(DescribeConfigsSynonym _object, short _version, boolean _serializeRecords) { if (_version < 1) { throw new UnsupportedVersionException("Can't write version " + _version + " of DescribeConfigsSynonym"); } ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); if (_object.value == null) { _node.set("value", NullNode.instance); } else { _node.set("value", new TextNode(_object.value)); } _node.set("source", new ShortNode(_object.source)); return _node; } public static JsonNode write(DescribeConfigsSynonym _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeDelegationTokenRequestData.java
/* * 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 DescribeDelegationTokenRequestData implements ApiMessage { List<DescribeDelegationTokenOwner> owners; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("owners", ArrayOf.nullable(DescribeDelegationTokenOwner.SCHEMA_0), "Each owner that we want to describe delegation tokens for, or null to describe all tokens.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("owners", CompactArrayOf.nullable(DescribeDelegationTokenOwner.SCHEMA_2), "Each owner that we want to describe delegation tokens for, or null to describe all tokens."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DescribeDelegationTokenRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeDelegationTokenRequestData() { this.owners = new ArrayList<DescribeDelegationTokenOwner>(0); } @Override public short apiKey() { return 41; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.owners = 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<DescribeDelegationTokenOwner> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeDelegationTokenOwner(_readable, _version)); } this.owners = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { this.owners = 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<DescribeDelegationTokenOwner> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeDelegationTokenOwner(_readable, _version)); } this.owners = 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; if (_version >= 2) { if (owners == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(owners.size() + 1); for (DescribeDelegationTokenOwner ownersElement : owners) { ownersElement.write(_writable, _cache, _version); } } } else { if (owners == null) { _writable.writeInt(-1); } else { _writable.writeInt(owners.size()); for (DescribeDelegationTokenOwner ownersElement : owners) { ownersElement.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; if (owners == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(4); } } else { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(owners.size() + 1)); } else { _size.addBytes(4); } for (DescribeDelegationTokenOwner ownersElement : owners) { ownersElement.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 DescribeDelegationTokenRequestData)) return false; DescribeDelegationTokenRequestData other = (DescribeDelegationTokenRequestData) obj; if (this.owners == null) { if (other.owners != null) return false; } else { if (!this.owners.equals(other.owners)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (owners == null ? 0 : owners.hashCode()); return hashCode; } @Override public DescribeDelegationTokenRequestData duplicate() { DescribeDelegationTokenRequestData _duplicate = new DescribeDelegationTokenRequestData(); if (owners == null) { _duplicate.owners = null; } else { ArrayList<DescribeDelegationTokenOwner> newOwners = new ArrayList<DescribeDelegationTokenOwner>(owners.size()); for (DescribeDelegationTokenOwner _element : owners) { newOwners.add(_element.duplicate()); } _duplicate.owners = newOwners; } return _duplicate; } @Override public String toString() { return "DescribeDelegationTokenRequestData(" + "owners=" + ((owners == null) ? "null" : MessageUtil.deepToString(owners.iterator())) + ")"; } public List<DescribeDelegationTokenOwner> owners() { return this.owners; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeDelegationTokenRequestData setOwners(List<DescribeDelegationTokenOwner> v) { this.owners = v; return this; } public static class DescribeDelegationTokenOwner implements Message { String principalType; String principalName; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("principal_type", Type.STRING, "The owner principal type."), new Field("principal_name", Type.STRING, "The owner principal name.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("principal_type", Type.COMPACT_STRING, "The owner principal type."), new Field("principal_name", Type.COMPACT_STRING, "The owner principal name."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DescribeDelegationTokenOwner(Readable _readable, short _version) { read(_readable, _version); } public DescribeDelegationTokenOwner() { this.principalType = ""; this.principalName = ""; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribeDelegationTokenOwner"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalType had invalid length " + length); } else { this.principalType = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalName had invalid length " + length); } else { this.principalName = _readable.readString(length); } } 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(principalType); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(principalName); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of DescribeDelegationTokenOwner"); } { byte[] _stringBytes = principalType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalType' field is too long to be serialized"); } _cache.cacheSerializedValue(principalType, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = principalName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalName' field is too long to be serialized"); } _cache.cacheSerializedValue(principalName, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 DescribeDelegationTokenOwner)) return false; DescribeDelegationTokenOwner other = (DescribeDelegationTokenOwner) obj; if (this.principalType == null) { if (other.principalType != null) return false; } else { if (!this.principalType.equals(other.principalType)) return false; } if (this.principalName == null) { if (other.principalName != null) return false; } else { if (!this.principalName.equals(other.principalName)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (principalType == null ? 0 : principalType.hashCode()); hashCode = 31 * hashCode + (principalName == null ? 0 : principalName.hashCode()); return hashCode; } @Override public DescribeDelegationTokenOwner duplicate() { DescribeDelegationTokenOwner _duplicate = new DescribeDelegationTokenOwner(); _duplicate.principalType = principalType; _duplicate.principalName = principalName; return _duplicate; } @Override public String toString() { return "DescribeDelegationTokenOwner(" + "principalType=" + ((principalType == null) ? "null" : "'" + principalType.toString() + "'") + ", principalName=" + ((principalName == null) ? "null" : "'" + principalName.toString() + "'") + ")"; } public String principalType() { return this.principalType; } public String principalName() { return this.principalName; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeDelegationTokenOwner setPrincipalType(String v) { this.principalType = v; return this; } public DescribeDelegationTokenOwner setPrincipalName(String v) { this.principalName = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeDelegationTokenRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import static org.apache.kafka.common.message.DescribeDelegationTokenRequestData.*; public class DescribeDelegationTokenRequestDataJsonConverter { public static DescribeDelegationTokenRequestData read(JsonNode _node, short _version) { DescribeDelegationTokenRequestData _object = new DescribeDelegationTokenRequestData(); JsonNode _ownersNode = _node.get("owners"); if (_ownersNode == null) { throw new RuntimeException("DescribeDelegationTokenRequestData: unable to locate field 'owners', which is mandatory in version " + _version); } else { if (_ownersNode.isNull()) { _object.owners = null; } else { if (!_ownersNode.isArray()) { throw new RuntimeException("DescribeDelegationTokenRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeDelegationTokenOwner> _collection = new ArrayList<DescribeDelegationTokenOwner>(_ownersNode.size()); _object.owners = _collection; for (JsonNode _element : _ownersNode) { _collection.add(DescribeDelegationTokenOwnerJsonConverter.read(_element, _version)); } } } return _object; } public static JsonNode write(DescribeDelegationTokenRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_object.owners == null) { _node.set("owners", NullNode.instance); } else { ArrayNode _ownersArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeDelegationTokenOwner _element : _object.owners) { _ownersArray.add(DescribeDelegationTokenOwnerJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("owners", _ownersArray); } return _node; } public static JsonNode write(DescribeDelegationTokenRequestData _object, short _version) { return write(_object, _version, true); } public static class DescribeDelegationTokenOwnerJsonConverter { public static DescribeDelegationTokenOwner read(JsonNode _node, short _version) { DescribeDelegationTokenOwner _object = new DescribeDelegationTokenOwner(); JsonNode _principalTypeNode = _node.get("principalType"); if (_principalTypeNode == null) { throw new RuntimeException("DescribeDelegationTokenOwner: unable to locate field 'principalType', which is mandatory in version " + _version); } else { if (!_principalTypeNode.isTextual()) { throw new RuntimeException("DescribeDelegationTokenOwner expected a string type, but got " + _node.getNodeType()); } _object.principalType = _principalTypeNode.asText(); } JsonNode _principalNameNode = _node.get("principalName"); if (_principalNameNode == null) { throw new RuntimeException("DescribeDelegationTokenOwner: unable to locate field 'principalName', which is mandatory in version " + _version); } else { if (!_principalNameNode.isTextual()) { throw new RuntimeException("DescribeDelegationTokenOwner expected a string type, but got " + _node.getNodeType()); } _object.principalName = _principalNameNode.asText(); } return _object; } public static JsonNode write(DescribeDelegationTokenOwner _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("principalType", new TextNode(_object.principalType)); _node.set("principalName", new TextNode(_object.principalName)); return _node; } public static JsonNode write(DescribeDelegationTokenOwner _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeDelegationTokenResponseData.java
/* * 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.Arrays; 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 org.apache.kafka.common.utils.Bytes; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class DescribeDelegationTokenResponseData implements ApiMessage { short errorCode; List<DescribedDelegationToken> tokens; int throttleTimeMs; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("tokens", new ArrayOf(DescribedDelegationToken.SCHEMA_0), "The tokens."), 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.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("tokens", new CompactArrayOf(DescribedDelegationToken.SCHEMA_2), "The tokens."), 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."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("tokens", new CompactArrayOf(DescribedDelegationToken.SCHEMA_3), "The tokens."), 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."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DescribeDelegationTokenResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeDelegationTokenResponseData() { this.errorCode = (short) 0; this.tokens = new ArrayList<DescribedDelegationToken>(0); this.throttleTimeMs = 0; } @Override public short apiKey() { return 41; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @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 tokens 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<DescribedDelegationToken> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribedDelegationToken(_readable, _version)); } this.tokens = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field tokens 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<DescribedDelegationToken> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribedDelegationToken(_readable, _version)); } this.tokens = newCollection; } } } this.throttleTimeMs = _readable.readInt(); 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(tokens.size() + 1); for (DescribedDelegationToken tokensElement : tokens) { tokensElement.write(_writable, _cache, _version); } } else { _writable.writeInt(tokens.size()); for (DescribedDelegationToken tokensElement : tokens) { tokensElement.write(_writable, _cache, _version); } } _writable.writeInt(throttleTimeMs); 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(tokens.size() + 1)); } else { _size.addBytes(4); } for (DescribedDelegationToken tokensElement : tokens) { tokensElement.addSize(_size, _cache, _version); } } _size.addBytes(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()); } } 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 DescribeDelegationTokenResponseData)) return false; DescribeDelegationTokenResponseData other = (DescribeDelegationTokenResponseData) obj; if (errorCode != other.errorCode) return false; if (this.tokens == null) { if (other.tokens != null) return false; } else { if (!this.tokens.equals(other.tokens)) return false; } if (throttleTimeMs != other.throttleTimeMs) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (tokens == null ? 0 : tokens.hashCode()); hashCode = 31 * hashCode + throttleTimeMs; return hashCode; } @Override public DescribeDelegationTokenResponseData duplicate() { DescribeDelegationTokenResponseData _duplicate = new DescribeDelegationTokenResponseData(); _duplicate.errorCode = errorCode; ArrayList<DescribedDelegationToken> newTokens = new ArrayList<DescribedDelegationToken>(tokens.size()); for (DescribedDelegationToken _element : tokens) { newTokens.add(_element.duplicate()); } _duplicate.tokens = newTokens; _duplicate.throttleTimeMs = throttleTimeMs; return _duplicate; } @Override public String toString() { return "DescribeDelegationTokenResponseData(" + "errorCode=" + errorCode + ", tokens=" + MessageUtil.deepToString(tokens.iterator()) + ", throttleTimeMs=" + throttleTimeMs + ")"; } public short errorCode() { return this.errorCode; } public List<DescribedDelegationToken> tokens() { return this.tokens; } public int throttleTimeMs() { return this.throttleTimeMs; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeDelegationTokenResponseData setErrorCode(short v) { this.errorCode = v; return this; } public DescribeDelegationTokenResponseData setTokens(List<DescribedDelegationToken> v) { this.tokens = v; return this; } public DescribeDelegationTokenResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public static class DescribedDelegationToken implements Message { String principalType; String principalName; String tokenRequesterPrincipalType; String tokenRequesterPrincipalName; long issueTimestamp; long expiryTimestamp; long maxTimestamp; String tokenId; byte[] hmac; List<DescribedDelegationTokenRenewer> renewers; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("principal_type", Type.STRING, "The token principal type."), new Field("principal_name", Type.STRING, "The token principal name."), new Field("issue_timestamp", Type.INT64, "The token issue timestamp in milliseconds."), new Field("expiry_timestamp", Type.INT64, "The token expiry timestamp in milliseconds."), new Field("max_timestamp", Type.INT64, "The token maximum timestamp length in milliseconds."), new Field("token_id", Type.STRING, "The token ID."), new Field("hmac", Type.BYTES, "The token HMAC."), new Field("renewers", new ArrayOf(DescribedDelegationTokenRenewer.SCHEMA_0), "Those who are able to renew this token before it expires.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("principal_type", Type.COMPACT_STRING, "The token principal type."), new Field("principal_name", Type.COMPACT_STRING, "The token principal name."), new Field("issue_timestamp", Type.INT64, "The token issue timestamp in milliseconds."), new Field("expiry_timestamp", Type.INT64, "The token expiry timestamp in milliseconds."), new Field("max_timestamp", Type.INT64, "The token maximum timestamp length in milliseconds."), new Field("token_id", Type.COMPACT_STRING, "The token ID."), new Field("hmac", Type.COMPACT_BYTES, "The token HMAC."), new Field("renewers", new CompactArrayOf(DescribedDelegationTokenRenewer.SCHEMA_2), "Those who are able to renew this token before it expires."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = new Schema( new Field("principal_type", Type.COMPACT_STRING, "The token principal type."), new Field("principal_name", Type.COMPACT_STRING, "The token principal name."), new Field("token_requester_principal_type", Type.COMPACT_STRING, "The principal type of the requester of the token."), new Field("token_requester_principal_name", Type.COMPACT_STRING, "The principal type of the requester of the token."), new Field("issue_timestamp", Type.INT64, "The token issue timestamp in milliseconds."), new Field("expiry_timestamp", Type.INT64, "The token expiry timestamp in milliseconds."), new Field("max_timestamp", Type.INT64, "The token maximum timestamp length in milliseconds."), new Field("token_id", Type.COMPACT_STRING, "The token ID."), new Field("hmac", Type.COMPACT_BYTES, "The token HMAC."), new Field("renewers", new CompactArrayOf(DescribedDelegationTokenRenewer.SCHEMA_2), "Those who are able to renew this token before it expires."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DescribedDelegationToken(Readable _readable, short _version) { read(_readable, _version); } public DescribedDelegationToken() { this.principalType = ""; this.principalName = ""; this.tokenRequesterPrincipalType = ""; this.tokenRequesterPrincipalName = ""; this.issueTimestamp = 0L; this.expiryTimestamp = 0L; this.maxTimestamp = 0L; this.tokenId = ""; this.hmac = Bytes.EMPTY; this.renewers = new ArrayList<DescribedDelegationTokenRenewer>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribedDelegationToken"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalType had invalid length " + length); } else { this.principalType = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalName had invalid length " + length); } else { this.principalName = _readable.readString(length); } } if (_version >= 3) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field tokenRequesterPrincipalType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field tokenRequesterPrincipalType had invalid length " + length); } else { this.tokenRequesterPrincipalType = _readable.readString(length); } } else { this.tokenRequesterPrincipalType = ""; } if (_version >= 3) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field tokenRequesterPrincipalName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field tokenRequesterPrincipalName had invalid length " + length); } else { this.tokenRequesterPrincipalName = _readable.readString(length); } } else { this.tokenRequesterPrincipalName = ""; } this.issueTimestamp = _readable.readLong(); this.expiryTimestamp = _readable.readLong(); this.maxTimestamp = _readable.readLong(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field tokenId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field tokenId had invalid length " + length); } else { this.tokenId = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readInt(); } if (length < 0) { throw new RuntimeException("non-nullable field hmac was serialized as null"); } else { byte[] newBytes = _readable.readArray(length); this.hmac = newBytes; } } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field renewers 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<DescribedDelegationTokenRenewer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribedDelegationTokenRenewer(_readable, _version)); } this.renewers = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field renewers 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<DescribedDelegationTokenRenewer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribedDelegationTokenRenewer(_readable, _version)); } this.renewers = 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; { byte[] _stringBytes = _cache.getSerializedValue(principalType); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(principalName); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 3) { { byte[] _stringBytes = _cache.getSerializedValue(tokenRequesterPrincipalType); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } else { if (!this.tokenRequesterPrincipalType.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default tokenRequesterPrincipalType at version " + _version); } } if (_version >= 3) { { byte[] _stringBytes = _cache.getSerializedValue(tokenRequesterPrincipalName); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } else { if (!this.tokenRequesterPrincipalName.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default tokenRequesterPrincipalName at version " + _version); } } _writable.writeLong(issueTimestamp); _writable.writeLong(expiryTimestamp); _writable.writeLong(maxTimestamp); { byte[] _stringBytes = _cache.getSerializedValue(tokenId); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(hmac.length + 1); } else { _writable.writeInt(hmac.length); } _writable.writeByteArray(hmac); if (_version >= 2) { _writable.writeUnsignedVarint(renewers.size() + 1); for (DescribedDelegationTokenRenewer renewersElement : renewers) { renewersElement.write(_writable, _cache, _version); } } else { _writable.writeInt(renewers.size()); for (DescribedDelegationTokenRenewer renewersElement : renewers) { renewersElement.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; if (_version > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of DescribedDelegationToken"); } { byte[] _stringBytes = principalType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalType' field is too long to be serialized"); } _cache.cacheSerializedValue(principalType, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = principalName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalName' field is too long to be serialized"); } _cache.cacheSerializedValue(principalName, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 3) { { byte[] _stringBytes = tokenRequesterPrincipalType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'tokenRequesterPrincipalType' field is too long to be serialized"); } _cache.cacheSerializedValue(tokenRequesterPrincipalType, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } } if (_version >= 3) { { byte[] _stringBytes = tokenRequesterPrincipalName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'tokenRequesterPrincipalName' field is too long to be serialized"); } _cache.cacheSerializedValue(tokenRequesterPrincipalName, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } } _size.addBytes(8); _size.addBytes(8); _size.addBytes(8); { byte[] _stringBytes = tokenId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'tokenId' field is too long to be serialized"); } _cache.cacheSerializedValue(tokenId, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { _size.addBytes(hmac.length); if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(hmac.length + 1)); } else { _size.addBytes(4); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(renewers.size() + 1)); } else { _size.addBytes(4); } for (DescribedDelegationTokenRenewer renewersElement : renewers) { renewersElement.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 DescribedDelegationToken)) return false; DescribedDelegationToken other = (DescribedDelegationToken) obj; if (this.principalType == null) { if (other.principalType != null) return false; } else { if (!this.principalType.equals(other.principalType)) return false; } if (this.principalName == null) { if (other.principalName != null) return false; } else { if (!this.principalName.equals(other.principalName)) return false; } if (this.tokenRequesterPrincipalType == null) { if (other.tokenRequesterPrincipalType != null) return false; } else { if (!this.tokenRequesterPrincipalType.equals(other.tokenRequesterPrincipalType)) return false; } if (this.tokenRequesterPrincipalName == null) { if (other.tokenRequesterPrincipalName != null) return false; } else { if (!this.tokenRequesterPrincipalName.equals(other.tokenRequesterPrincipalName)) return false; } if (issueTimestamp != other.issueTimestamp) return false; if (expiryTimestamp != other.expiryTimestamp) return false; if (maxTimestamp != other.maxTimestamp) return false; if (this.tokenId == null) { if (other.tokenId != null) return false; } else { if (!this.tokenId.equals(other.tokenId)) return false; } if (!Arrays.equals(this.hmac, other.hmac)) return false; if (this.renewers == null) { if (other.renewers != null) return false; } else { if (!this.renewers.equals(other.renewers)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (principalType == null ? 0 : principalType.hashCode()); hashCode = 31 * hashCode + (principalName == null ? 0 : principalName.hashCode()); hashCode = 31 * hashCode + (tokenRequesterPrincipalType == null ? 0 : tokenRequesterPrincipalType.hashCode()); hashCode = 31 * hashCode + (tokenRequesterPrincipalName == null ? 0 : tokenRequesterPrincipalName.hashCode()); hashCode = 31 * hashCode + ((int) (issueTimestamp >> 32) ^ (int) issueTimestamp); hashCode = 31 * hashCode + ((int) (expiryTimestamp >> 32) ^ (int) expiryTimestamp); hashCode = 31 * hashCode + ((int) (maxTimestamp >> 32) ^ (int) maxTimestamp); hashCode = 31 * hashCode + (tokenId == null ? 0 : tokenId.hashCode()); hashCode = 31 * hashCode + Arrays.hashCode(hmac); hashCode = 31 * hashCode + (renewers == null ? 0 : renewers.hashCode()); return hashCode; } @Override public DescribedDelegationToken duplicate() { DescribedDelegationToken _duplicate = new DescribedDelegationToken(); _duplicate.principalType = principalType; _duplicate.principalName = principalName; _duplicate.tokenRequesterPrincipalType = tokenRequesterPrincipalType; _duplicate.tokenRequesterPrincipalName = tokenRequesterPrincipalName; _duplicate.issueTimestamp = issueTimestamp; _duplicate.expiryTimestamp = expiryTimestamp; _duplicate.maxTimestamp = maxTimestamp; _duplicate.tokenId = tokenId; _duplicate.hmac = MessageUtil.duplicate(hmac); ArrayList<DescribedDelegationTokenRenewer> newRenewers = new ArrayList<DescribedDelegationTokenRenewer>(renewers.size()); for (DescribedDelegationTokenRenewer _element : renewers) { newRenewers.add(_element.duplicate()); } _duplicate.renewers = newRenewers; return _duplicate; } @Override public String toString() { return "DescribedDelegationToken(" + "principalType=" + ((principalType == null) ? "null" : "'" + principalType.toString() + "'") + ", principalName=" + ((principalName == null) ? "null" : "'" + principalName.toString() + "'") + ", tokenRequesterPrincipalType=" + ((tokenRequesterPrincipalType == null) ? "null" : "'" + tokenRequesterPrincipalType.toString() + "'") + ", tokenRequesterPrincipalName=" + ((tokenRequesterPrincipalName == null) ? "null" : "'" + tokenRequesterPrincipalName.toString() + "'") + ", issueTimestamp=" + issueTimestamp + ", expiryTimestamp=" + expiryTimestamp + ", maxTimestamp=" + maxTimestamp + ", tokenId=" + ((tokenId == null) ? "null" : "'" + tokenId.toString() + "'") + ", hmac=" + Arrays.toString(hmac) + ", renewers=" + MessageUtil.deepToString(renewers.iterator()) + ")"; } public String principalType() { return this.principalType; } public String principalName() { return this.principalName; } public String tokenRequesterPrincipalType() { return this.tokenRequesterPrincipalType; } public String tokenRequesterPrincipalName() { return this.tokenRequesterPrincipalName; } public long issueTimestamp() { return this.issueTimestamp; } public long expiryTimestamp() { return this.expiryTimestamp; } public long maxTimestamp() { return this.maxTimestamp; } public String tokenId() { return this.tokenId; } public byte[] hmac() { return this.hmac; } public List<DescribedDelegationTokenRenewer> renewers() { return this.renewers; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribedDelegationToken setPrincipalType(String v) { this.principalType = v; return this; } public DescribedDelegationToken setPrincipalName(String v) { this.principalName = v; return this; } public DescribedDelegationToken setTokenRequesterPrincipalType(String v) { this.tokenRequesterPrincipalType = v; return this; } public DescribedDelegationToken setTokenRequesterPrincipalName(String v) { this.tokenRequesterPrincipalName = v; return this; } public DescribedDelegationToken setIssueTimestamp(long v) { this.issueTimestamp = v; return this; } public DescribedDelegationToken setExpiryTimestamp(long v) { this.expiryTimestamp = v; return this; } public DescribedDelegationToken setMaxTimestamp(long v) { this.maxTimestamp = v; return this; } public DescribedDelegationToken setTokenId(String v) { this.tokenId = v; return this; } public DescribedDelegationToken setHmac(byte[] v) { this.hmac = v; return this; } public DescribedDelegationToken setRenewers(List<DescribedDelegationTokenRenewer> v) { this.renewers = v; return this; } } public static class DescribedDelegationTokenRenewer implements Message { String principalType; String principalName; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("principal_type", Type.STRING, "The renewer principal type"), new Field("principal_name", Type.STRING, "The renewer principal name") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("principal_type", Type.COMPACT_STRING, "The renewer principal type"), new Field("principal_name", Type.COMPACT_STRING, "The renewer principal name"), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 3; public DescribedDelegationTokenRenewer(Readable _readable, short _version) { read(_readable, _version); } public DescribedDelegationTokenRenewer() { this.principalType = ""; this.principalName = ""; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 3; } @Override public void read(Readable _readable, short _version) { if (_version > 3) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribedDelegationTokenRenewer"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalType had invalid length " + length); } else { this.principalType = _readable.readString(length); } } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field principalName was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field principalName had invalid length " + length); } else { this.principalName = _readable.readString(length); } } 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(principalType); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(principalName); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } 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 > 3) { throw new UnsupportedVersionException("Can't size version " + _version + " of DescribedDelegationTokenRenewer"); } { byte[] _stringBytes = principalType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalType' field is too long to be serialized"); } _cache.cacheSerializedValue(principalType, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = principalName.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'principalName' field is too long to be serialized"); } _cache.cacheSerializedValue(principalName, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 DescribedDelegationTokenRenewer)) return false; DescribedDelegationTokenRenewer other = (DescribedDelegationTokenRenewer) obj; if (this.principalType == null) { if (other.principalType != null) return false; } else { if (!this.principalType.equals(other.principalType)) return false; } if (this.principalName == null) { if (other.principalName != null) return false; } else { if (!this.principalName.equals(other.principalName)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (principalType == null ? 0 : principalType.hashCode()); hashCode = 31 * hashCode + (principalName == null ? 0 : principalName.hashCode()); return hashCode; } @Override public DescribedDelegationTokenRenewer duplicate() { DescribedDelegationTokenRenewer _duplicate = new DescribedDelegationTokenRenewer(); _duplicate.principalType = principalType; _duplicate.principalName = principalName; return _duplicate; } @Override public String toString() { return "DescribedDelegationTokenRenewer(" + "principalType=" + ((principalType == null) ? "null" : "'" + principalType.toString() + "'") + ", principalName=" + ((principalName == null) ? "null" : "'" + principalName.toString() + "'") + ")"; } public String principalType() { return this.principalType; } public String principalName() { return this.principalName; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribedDelegationTokenRenewer setPrincipalType(String v) { this.principalType = v; return this; } public DescribedDelegationTokenRenewer setPrincipalName(String v) { this.principalName = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeDelegationTokenResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BinaryNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import java.util.Arrays; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeDelegationTokenResponseData.*; public class DescribeDelegationTokenResponseDataJsonConverter { public static DescribeDelegationTokenResponseData read(JsonNode _node, short _version) { DescribeDelegationTokenResponseData _object = new DescribeDelegationTokenResponseData(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeDelegationTokenResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeDelegationTokenResponseData"); } JsonNode _tokensNode = _node.get("tokens"); if (_tokensNode == null) { throw new RuntimeException("DescribeDelegationTokenResponseData: unable to locate field 'tokens', which is mandatory in version " + _version); } else { if (!_tokensNode.isArray()) { throw new RuntimeException("DescribeDelegationTokenResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribedDelegationToken> _collection = new ArrayList<DescribedDelegationToken>(_tokensNode.size()); _object.tokens = _collection; for (JsonNode _element : _tokensNode) { _collection.add(DescribedDelegationTokenJsonConverter.read(_element, _version)); } } JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeDelegationTokenResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeDelegationTokenResponseData"); } return _object; } public static JsonNode write(DescribeDelegationTokenResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); ArrayNode _tokensArray = new ArrayNode(JsonNodeFactory.instance); for (DescribedDelegationToken _element : _object.tokens) { _tokensArray.add(DescribedDelegationTokenJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("tokens", _tokensArray); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); return _node; } public static JsonNode write(DescribeDelegationTokenResponseData _object, short _version) { return write(_object, _version, true); } public static class DescribedDelegationTokenJsonConverter { public static DescribedDelegationToken read(JsonNode _node, short _version) { DescribedDelegationToken _object = new DescribedDelegationToken(); JsonNode _principalTypeNode = _node.get("principalType"); if (_principalTypeNode == null) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'principalType', which is mandatory in version " + _version); } else { if (!_principalTypeNode.isTextual()) { throw new RuntimeException("DescribedDelegationToken expected a string type, but got " + _node.getNodeType()); } _object.principalType = _principalTypeNode.asText(); } JsonNode _principalNameNode = _node.get("principalName"); if (_principalNameNode == null) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'principalName', which is mandatory in version " + _version); } else { if (!_principalNameNode.isTextual()) { throw new RuntimeException("DescribedDelegationToken expected a string type, but got " + _node.getNodeType()); } _object.principalName = _principalNameNode.asText(); } JsonNode _tokenRequesterPrincipalTypeNode = _node.get("tokenRequesterPrincipalType"); if (_tokenRequesterPrincipalTypeNode == null) { if (_version >= 3) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'tokenRequesterPrincipalType', which is mandatory in version " + _version); } else { _object.tokenRequesterPrincipalType = ""; } } else { if (!_tokenRequesterPrincipalTypeNode.isTextual()) { throw new RuntimeException("DescribedDelegationToken expected a string type, but got " + _node.getNodeType()); } _object.tokenRequesterPrincipalType = _tokenRequesterPrincipalTypeNode.asText(); } JsonNode _tokenRequesterPrincipalNameNode = _node.get("tokenRequesterPrincipalName"); if (_tokenRequesterPrincipalNameNode == null) { if (_version >= 3) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'tokenRequesterPrincipalName', which is mandatory in version " + _version); } else { _object.tokenRequesterPrincipalName = ""; } } else { if (!_tokenRequesterPrincipalNameNode.isTextual()) { throw new RuntimeException("DescribedDelegationToken expected a string type, but got " + _node.getNodeType()); } _object.tokenRequesterPrincipalName = _tokenRequesterPrincipalNameNode.asText(); } JsonNode _issueTimestampNode = _node.get("issueTimestamp"); if (_issueTimestampNode == null) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'issueTimestamp', which is mandatory in version " + _version); } else { _object.issueTimestamp = MessageUtil.jsonNodeToLong(_issueTimestampNode, "DescribedDelegationToken"); } JsonNode _expiryTimestampNode = _node.get("expiryTimestamp"); if (_expiryTimestampNode == null) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'expiryTimestamp', which is mandatory in version " + _version); } else { _object.expiryTimestamp = MessageUtil.jsonNodeToLong(_expiryTimestampNode, "DescribedDelegationToken"); } JsonNode _maxTimestampNode = _node.get("maxTimestamp"); if (_maxTimestampNode == null) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'maxTimestamp', which is mandatory in version " + _version); } else { _object.maxTimestamp = MessageUtil.jsonNodeToLong(_maxTimestampNode, "DescribedDelegationToken"); } JsonNode _tokenIdNode = _node.get("tokenId"); if (_tokenIdNode == null) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'tokenId', which is mandatory in version " + _version); } else { if (!_tokenIdNode.isTextual()) { throw new RuntimeException("DescribedDelegationToken expected a string type, but got " + _node.getNodeType()); } _object.tokenId = _tokenIdNode.asText(); } JsonNode _hmacNode = _node.get("hmac"); if (_hmacNode == null) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'hmac', which is mandatory in version " + _version); } else { _object.hmac = MessageUtil.jsonNodeToBinary(_hmacNode, "DescribedDelegationToken"); } JsonNode _renewersNode = _node.get("renewers"); if (_renewersNode == null) { throw new RuntimeException("DescribedDelegationToken: unable to locate field 'renewers', which is mandatory in version " + _version); } else { if (!_renewersNode.isArray()) { throw new RuntimeException("DescribedDelegationToken expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribedDelegationTokenRenewer> _collection = new ArrayList<DescribedDelegationTokenRenewer>(_renewersNode.size()); _object.renewers = _collection; for (JsonNode _element : _renewersNode) { _collection.add(DescribedDelegationTokenRenewerJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribedDelegationToken _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("principalType", new TextNode(_object.principalType)); _node.set("principalName", new TextNode(_object.principalName)); if (_version >= 3) { _node.set("tokenRequesterPrincipalType", new TextNode(_object.tokenRequesterPrincipalType)); } else { if (!_object.tokenRequesterPrincipalType.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default tokenRequesterPrincipalType at version " + _version); } } if (_version >= 3) { _node.set("tokenRequesterPrincipalName", new TextNode(_object.tokenRequesterPrincipalName)); } else { if (!_object.tokenRequesterPrincipalName.equals("")) { throw new UnsupportedVersionException("Attempted to write a non-default tokenRequesterPrincipalName at version " + _version); } } _node.set("issueTimestamp", new LongNode(_object.issueTimestamp)); _node.set("expiryTimestamp", new LongNode(_object.expiryTimestamp)); _node.set("maxTimestamp", new LongNode(_object.maxTimestamp)); _node.set("tokenId", new TextNode(_object.tokenId)); _node.set("hmac", new BinaryNode(Arrays.copyOf(_object.hmac, _object.hmac.length))); ArrayNode _renewersArray = new ArrayNode(JsonNodeFactory.instance); for (DescribedDelegationTokenRenewer _element : _object.renewers) { _renewersArray.add(DescribedDelegationTokenRenewerJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("renewers", _renewersArray); return _node; } public static JsonNode write(DescribedDelegationToken _object, short _version) { return write(_object, _version, true); } } public static class DescribedDelegationTokenRenewerJsonConverter { public static DescribedDelegationTokenRenewer read(JsonNode _node, short _version) { DescribedDelegationTokenRenewer _object = new DescribedDelegationTokenRenewer(); JsonNode _principalTypeNode = _node.get("principalType"); if (_principalTypeNode == null) { throw new RuntimeException("DescribedDelegationTokenRenewer: unable to locate field 'principalType', which is mandatory in version " + _version); } else { if (!_principalTypeNode.isTextual()) { throw new RuntimeException("DescribedDelegationTokenRenewer expected a string type, but got " + _node.getNodeType()); } _object.principalType = _principalTypeNode.asText(); } JsonNode _principalNameNode = _node.get("principalName"); if (_principalNameNode == null) { throw new RuntimeException("DescribedDelegationTokenRenewer: unable to locate field 'principalName', which is mandatory in version " + _version); } else { if (!_principalNameNode.isTextual()) { throw new RuntimeException("DescribedDelegationTokenRenewer expected a string type, but got " + _node.getNodeType()); } _object.principalName = _principalNameNode.asText(); } return _object; } public static JsonNode write(DescribedDelegationTokenRenewer _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("principalType", new TextNode(_object.principalType)); _node.set("principalName", new TextNode(_object.principalName)); return _node; } public static JsonNode write(DescribedDelegationTokenRenewer _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeGroupsRequestData.java
/* * 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.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 DescribeGroupsRequestData implements ApiMessage { List<String> groups; boolean includeAuthorizedOperations; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("groups", new ArrayOf(Type.STRING), "The names of the groups to describe") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = new Schema( new Field("groups", new ArrayOf(Type.STRING), "The names of the groups to describe"), new Field("include_authorized_operations", Type.BOOLEAN, "Whether to include authorized operations.") ); public static final Schema SCHEMA_4 = SCHEMA_3; public static final Schema SCHEMA_5 = new Schema( new Field("groups", new CompactArrayOf(Type.COMPACT_STRING), "The names of the groups to describe"), new Field("include_authorized_operations", Type.BOOLEAN, "Whether to include authorized operations."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 5; public DescribeGroupsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeGroupsRequestData() { this.groups = new ArrayList<String>(0); this.includeAuthorizedOperations = false; } @Override public short apiKey() { return 15; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 5; } @Override public void read(Readable _readable, short _version) { { if (_version >= 5) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field groups 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field groups element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field groups element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.groups = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field groups 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readShort(); if (length < 0) { throw new RuntimeException("non-nullable field groups element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field groups element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.groups = newCollection; } } } if (_version >= 3) { this.includeAuthorizedOperations = _readable.readByte() != 0; } else { this.includeAuthorizedOperations = false; } this._unknownTaggedFields = null; if (_version >= 5) { 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; if (_version >= 5) { _writable.writeUnsignedVarint(groups.size() + 1); for (String groupsElement : groups) { { byte[] _stringBytes = _cache.getSerializedValue(groupsElement); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } } else { _writable.writeInt(groups.size()); for (String groupsElement : groups) { { byte[] _stringBytes = _cache.getSerializedValue(groupsElement); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } } } if (_version >= 3) { _writable.writeByte(includeAuthorizedOperations ? (byte) 1 : (byte) 0); } else { if (this.includeAuthorizedOperations) { throw new UnsupportedVersionException("Attempted to write a non-default includeAuthorizedOperations at version " + _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(groups.size() + 1)); } else { _size.addBytes(4); } for (String groupsElement : groups) { byte[] _stringBytes = groupsElement.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'groupsElement' field is too long to be serialized"); } _cache.cacheSerializedValue(groupsElement, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } } if (_version >= 3) { _size.addBytes(1); } 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 >= 5) { _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 DescribeGroupsRequestData)) return false; DescribeGroupsRequestData other = (DescribeGroupsRequestData) obj; if (this.groups == null) { if (other.groups != null) return false; } else { if (!this.groups.equals(other.groups)) return false; } if (includeAuthorizedOperations != other.includeAuthorizedOperations) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (groups == null ? 0 : groups.hashCode()); hashCode = 31 * hashCode + (includeAuthorizedOperations ? 1231 : 1237); return hashCode; } @Override public DescribeGroupsRequestData duplicate() { DescribeGroupsRequestData _duplicate = new DescribeGroupsRequestData(); ArrayList<String> newGroups = new ArrayList<String>(groups.size()); for (String _element : groups) { newGroups.add(_element); } _duplicate.groups = newGroups; _duplicate.includeAuthorizedOperations = includeAuthorizedOperations; return _duplicate; } @Override public String toString() { return "DescribeGroupsRequestData(" + "groups=" + MessageUtil.deepToString(groups.iterator()) + ", includeAuthorizedOperations=" + (includeAuthorizedOperations ? "true" : "false") + ")"; } public List<String> groups() { return this.groups; } public boolean includeAuthorizedOperations() { return this.includeAuthorizedOperations; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeGroupsRequestData setGroups(List<String> v) { this.groups = v; return this; } public DescribeGroupsRequestData setIncludeAuthorizedOperations(boolean v) { this.includeAuthorizedOperations = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeGroupsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import static org.apache.kafka.common.message.DescribeGroupsRequestData.*; public class DescribeGroupsRequestDataJsonConverter { public static DescribeGroupsRequestData read(JsonNode _node, short _version) { DescribeGroupsRequestData _object = new DescribeGroupsRequestData(); JsonNode _groupsNode = _node.get("groups"); if (_groupsNode == null) { throw new RuntimeException("DescribeGroupsRequestData: unable to locate field 'groups', which is mandatory in version " + _version); } else { if (!_groupsNode.isArray()) { throw new RuntimeException("DescribeGroupsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<String> _collection = new ArrayList<String>(_groupsNode.size()); _object.groups = _collection; for (JsonNode _element : _groupsNode) { if (!_element.isTextual()) { throw new RuntimeException("DescribeGroupsRequestData element expected a string type, but got " + _node.getNodeType()); } _collection.add(_element.asText()); } } JsonNode _includeAuthorizedOperationsNode = _node.get("includeAuthorizedOperations"); if (_includeAuthorizedOperationsNode == null) { if (_version >= 3) { throw new RuntimeException("DescribeGroupsRequestData: unable to locate field 'includeAuthorizedOperations', which is mandatory in version " + _version); } else { _object.includeAuthorizedOperations = false; } } else { if (!_includeAuthorizedOperationsNode.isBoolean()) { throw new RuntimeException("DescribeGroupsRequestData expected Boolean type, but got " + _node.getNodeType()); } _object.includeAuthorizedOperations = _includeAuthorizedOperationsNode.asBoolean(); } return _object; } public static JsonNode write(DescribeGroupsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _groupsArray = new ArrayNode(JsonNodeFactory.instance); for (String _element : _object.groups) { _groupsArray.add(new TextNode(_element)); } _node.set("groups", _groupsArray); if (_version >= 3) { _node.set("includeAuthorizedOperations", BooleanNode.valueOf(_object.includeAuthorizedOperations)); } else { if (_object.includeAuthorizedOperations) { throw new UnsupportedVersionException("Attempted to write a non-default includeAuthorizedOperations at version " + _version); } } return _node; } public static JsonNode write(DescribeGroupsRequestData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeGroupsResponseData.java
/* * 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.Arrays; 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 org.apache.kafka.common.utils.Bytes; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class DescribeGroupsResponseData implements ApiMessage { int throttleTimeMs; List<DescribedGroup> groups; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("groups", new ArrayOf(DescribedGroup.SCHEMA_0), "Each described group.") ); public static final Schema SCHEMA_1 = 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("groups", new ArrayOf(DescribedGroup.SCHEMA_0), "Each described group.") ); public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = 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("groups", new ArrayOf(DescribedGroup.SCHEMA_3), "Each described group.") ); public static final Schema SCHEMA_4 = 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("groups", new ArrayOf(DescribedGroup.SCHEMA_4), "Each described group.") ); public static final Schema SCHEMA_5 = 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("groups", new CompactArrayOf(DescribedGroup.SCHEMA_5), "Each described group."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 5; public DescribeGroupsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeGroupsResponseData() { this.throttleTimeMs = 0; this.groups = new ArrayList<DescribedGroup>(0); } @Override public short apiKey() { return 15; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 5; } @Override public void read(Readable _readable, short _version) { if (_version >= 1) { this.throttleTimeMs = _readable.readInt(); } else { this.throttleTimeMs = 0; } { if (_version >= 5) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field groups 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<DescribedGroup> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribedGroup(_readable, _version)); } this.groups = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field groups 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<DescribedGroup> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribedGroup(_readable, _version)); } this.groups = newCollection; } } } this._unknownTaggedFields = null; if (_version >= 5) { 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; if (_version >= 1) { _writable.writeInt(throttleTimeMs); } if (_version >= 5) { _writable.writeUnsignedVarint(groups.size() + 1); for (DescribedGroup groupsElement : groups) { groupsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(groups.size()); for (DescribedGroup groupsElement : groups) { groupsElement.write(_writable, _cache, _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 >= 1) { _size.addBytes(4); } { if (_version >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(groups.size() + 1)); } else { _size.addBytes(4); } for (DescribedGroup groupsElement : groups) { groupsElement.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 >= 5) { _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 DescribeGroupsResponseData)) return false; DescribeGroupsResponseData other = (DescribeGroupsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.groups == null) { if (other.groups != null) return false; } else { if (!this.groups.equals(other.groups)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (groups == null ? 0 : groups.hashCode()); return hashCode; } @Override public DescribeGroupsResponseData duplicate() { DescribeGroupsResponseData _duplicate = new DescribeGroupsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; ArrayList<DescribedGroup> newGroups = new ArrayList<DescribedGroup>(groups.size()); for (DescribedGroup _element : groups) { newGroups.add(_element.duplicate()); } _duplicate.groups = newGroups; return _duplicate; } @Override public String toString() { return "DescribeGroupsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", groups=" + MessageUtil.deepToString(groups.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public List<DescribedGroup> groups() { return this.groups; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeGroupsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeGroupsResponseData setGroups(List<DescribedGroup> v) { this.groups = v; return this; } public static class DescribedGroup implements Message { short errorCode; String groupId; String groupState; String protocolType; String protocolData; List<DescribedGroupMember> members; int authorizedOperations; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The describe error, or 0 if there was no error."), new Field("group_id", Type.STRING, "The group ID string."), new Field("group_state", Type.STRING, "The group state string, or the empty string."), new Field("protocol_type", Type.STRING, "The group protocol type, or the empty string."), new Field("protocol_data", Type.STRING, "The group protocol data, or the empty string."), new Field("members", new ArrayOf(DescribedGroupMember.SCHEMA_0), "The group members.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = new Schema( new Field("error_code", Type.INT16, "The describe error, or 0 if there was no error."), new Field("group_id", Type.STRING, "The group ID string."), new Field("group_state", Type.STRING, "The group state string, or the empty string."), new Field("protocol_type", Type.STRING, "The group protocol type, or the empty string."), new Field("protocol_data", Type.STRING, "The group protocol data, or the empty string."), new Field("members", new ArrayOf(DescribedGroupMember.SCHEMA_0), "The group members."), new Field("authorized_operations", Type.INT32, "32-bit bitfield to represent authorized operations for this group.") ); public static final Schema SCHEMA_4 = new Schema( new Field("error_code", Type.INT16, "The describe error, or 0 if there was no error."), new Field("group_id", Type.STRING, "The group ID string."), new Field("group_state", Type.STRING, "The group state string, or the empty string."), new Field("protocol_type", Type.STRING, "The group protocol type, or the empty string."), new Field("protocol_data", Type.STRING, "The group protocol data, or the empty string."), new Field("members", new ArrayOf(DescribedGroupMember.SCHEMA_4), "The group members."), new Field("authorized_operations", Type.INT32, "32-bit bitfield to represent authorized operations for this group.") ); public static final Schema SCHEMA_5 = new Schema( new Field("error_code", Type.INT16, "The describe error, or 0 if there was no error."), new Field("group_id", Type.COMPACT_STRING, "The group ID string."), new Field("group_state", Type.COMPACT_STRING, "The group state string, or the empty string."), new Field("protocol_type", Type.COMPACT_STRING, "The group protocol type, or the empty string."), new Field("protocol_data", Type.COMPACT_STRING, "The group protocol data, or the empty string."), new Field("members", new CompactArrayOf(DescribedGroupMember.SCHEMA_5), "The group members."), new Field("authorized_operations", Type.INT32, "32-bit bitfield to represent authorized operations for this group."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 5; public DescribedGroup(Readable _readable, short _version) { read(_readable, _version); } public DescribedGroup() { this.errorCode = (short) 0; this.groupId = ""; this.groupState = ""; this.protocolType = ""; this.protocolData = ""; this.members = new ArrayList<DescribedGroupMember>(0); this.authorizedOperations = -2147483648; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 5; } @Override public void read(Readable _readable, short _version) { if (_version > 5) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribedGroup"); } this.errorCode = _readable.readShort(); { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field groupId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field groupId had invalid length " + length); } else { this.groupId = _readable.readString(length); } } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field groupState was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field groupState had invalid length " + length); } else { this.groupState = _readable.readString(length); } } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field protocolType was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field protocolType had invalid length " + length); } else { this.protocolType = _readable.readString(length); } } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field protocolData was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field protocolData had invalid length " + length); } else { this.protocolData = _readable.readString(length); } } { if (_version >= 5) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field members 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<DescribedGroupMember> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribedGroupMember(_readable, _version)); } this.members = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field members 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<DescribedGroupMember> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribedGroupMember(_readable, _version)); } this.members = newCollection; } } } if (_version >= 3) { this.authorizedOperations = _readable.readInt(); } else { this.authorizedOperations = -2147483648; } this._unknownTaggedFields = null; if (_version >= 5) { 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); { byte[] _stringBytes = _cache.getSerializedValue(groupId); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(groupState); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(protocolType); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(protocolData); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 5) { _writable.writeUnsignedVarint(members.size() + 1); for (DescribedGroupMember membersElement : members) { membersElement.write(_writable, _cache, _version); } } else { _writable.writeInt(members.size()); for (DescribedGroupMember membersElement : members) { membersElement.write(_writable, _cache, _version); } } if (_version >= 3) { _writable.writeInt(authorizedOperations); } else { if (this.authorizedOperations != -2147483648) { throw new UnsupportedVersionException("Attempted to write a non-default authorizedOperations at version " + _version); } } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 > 5) { throw new UnsupportedVersionException("Can't size version " + _version + " of DescribedGroup"); } _size.addBytes(2); { byte[] _stringBytes = groupId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'groupId' field is too long to be serialized"); } _cache.cacheSerializedValue(groupId, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = groupState.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'groupState' field is too long to be serialized"); } _cache.cacheSerializedValue(groupState, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = protocolType.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'protocolType' field is too long to be serialized"); } _cache.cacheSerializedValue(protocolType, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = protocolData.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'protocolData' field is too long to be serialized"); } _cache.cacheSerializedValue(protocolData, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(members.size() + 1)); } else { _size.addBytes(4); } for (DescribedGroupMember membersElement : members) { membersElement.addSize(_size, _cache, _version); } } if (_version >= 3) { _size.addBytes(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()); } } if (_version >= 5) { _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 DescribedGroup)) return false; DescribedGroup other = (DescribedGroup) obj; if (errorCode != other.errorCode) return false; if (this.groupId == null) { if (other.groupId != null) return false; } else { if (!this.groupId.equals(other.groupId)) return false; } if (this.groupState == null) { if (other.groupState != null) return false; } else { if (!this.groupState.equals(other.groupState)) return false; } if (this.protocolType == null) { if (other.protocolType != null) return false; } else { if (!this.protocolType.equals(other.protocolType)) return false; } if (this.protocolData == null) { if (other.protocolData != null) return false; } else { if (!this.protocolData.equals(other.protocolData)) return false; } if (this.members == null) { if (other.members != null) return false; } else { if (!this.members.equals(other.members)) return false; } if (authorizedOperations != other.authorizedOperations) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (groupId == null ? 0 : groupId.hashCode()); hashCode = 31 * hashCode + (groupState == null ? 0 : groupState.hashCode()); hashCode = 31 * hashCode + (protocolType == null ? 0 : protocolType.hashCode()); hashCode = 31 * hashCode + (protocolData == null ? 0 : protocolData.hashCode()); hashCode = 31 * hashCode + (members == null ? 0 : members.hashCode()); hashCode = 31 * hashCode + authorizedOperations; return hashCode; } @Override public DescribedGroup duplicate() { DescribedGroup _duplicate = new DescribedGroup(); _duplicate.errorCode = errorCode; _duplicate.groupId = groupId; _duplicate.groupState = groupState; _duplicate.protocolType = protocolType; _duplicate.protocolData = protocolData; ArrayList<DescribedGroupMember> newMembers = new ArrayList<DescribedGroupMember>(members.size()); for (DescribedGroupMember _element : members) { newMembers.add(_element.duplicate()); } _duplicate.members = newMembers; _duplicate.authorizedOperations = authorizedOperations; return _duplicate; } @Override public String toString() { return "DescribedGroup(" + "errorCode=" + errorCode + ", groupId=" + ((groupId == null) ? "null" : "'" + groupId.toString() + "'") + ", groupState=" + ((groupState == null) ? "null" : "'" + groupState.toString() + "'") + ", protocolType=" + ((protocolType == null) ? "null" : "'" + protocolType.toString() + "'") + ", protocolData=" + ((protocolData == null) ? "null" : "'" + protocolData.toString() + "'") + ", members=" + MessageUtil.deepToString(members.iterator()) + ", authorizedOperations=" + authorizedOperations + ")"; } public short errorCode() { return this.errorCode; } public String groupId() { return this.groupId; } public String groupState() { return this.groupState; } public String protocolType() { return this.protocolType; } public String protocolData() { return this.protocolData; } public List<DescribedGroupMember> members() { return this.members; } public int authorizedOperations() { return this.authorizedOperations; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribedGroup setErrorCode(short v) { this.errorCode = v; return this; } public DescribedGroup setGroupId(String v) { this.groupId = v; return this; } public DescribedGroup setGroupState(String v) { this.groupState = v; return this; } public DescribedGroup setProtocolType(String v) { this.protocolType = v; return this; } public DescribedGroup setProtocolData(String v) { this.protocolData = v; return this; } public DescribedGroup setMembers(List<DescribedGroupMember> v) { this.members = v; return this; } public DescribedGroup setAuthorizedOperations(int v) { this.authorizedOperations = v; return this; } } public static class DescribedGroupMember implements Message { String memberId; String groupInstanceId; String clientId; String clientHost; byte[] memberMetadata; byte[] memberAssignment; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("member_id", Type.STRING, "The member ID assigned by the group coordinator."), new Field("client_id", Type.STRING, "The client ID used in the member's latest join group request."), new Field("client_host", Type.STRING, "The client host."), new Field("member_metadata", Type.BYTES, "The metadata corresponding to the current group protocol in use."), new Field("member_assignment", Type.BYTES, "The current assignment provided by the group leader.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = SCHEMA_1; public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = new Schema( new Field("member_id", Type.STRING, "The member ID assigned by the group coordinator."), new Field("group_instance_id", Type.NULLABLE_STRING, "The unique identifier of the consumer instance provided by end user."), new Field("client_id", Type.STRING, "The client ID used in the member's latest join group request."), new Field("client_host", Type.STRING, "The client host."), new Field("member_metadata", Type.BYTES, "The metadata corresponding to the current group protocol in use."), new Field("member_assignment", Type.BYTES, "The current assignment provided by the group leader.") ); public static final Schema SCHEMA_5 = new Schema( new Field("member_id", Type.COMPACT_STRING, "The member ID assigned by the group coordinator."), new Field("group_instance_id", Type.COMPACT_NULLABLE_STRING, "The unique identifier of the consumer instance provided by end user."), new Field("client_id", Type.COMPACT_STRING, "The client ID used in the member's latest join group request."), new Field("client_host", Type.COMPACT_STRING, "The client host."), new Field("member_metadata", Type.COMPACT_BYTES, "The metadata corresponding to the current group protocol in use."), new Field("member_assignment", Type.COMPACT_BYTES, "The current assignment provided by the group leader."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2, SCHEMA_3, SCHEMA_4, SCHEMA_5 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 5; public DescribedGroupMember(Readable _readable, short _version) { read(_readable, _version); } public DescribedGroupMember() { this.memberId = ""; this.groupInstanceId = null; this.clientId = ""; this.clientHost = ""; this.memberMetadata = Bytes.EMPTY; this.memberAssignment = Bytes.EMPTY; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 5; } @Override public void read(Readable _readable, short _version) { if (_version > 5) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribedGroupMember"); } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field memberId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field memberId had invalid length " + length); } else { this.memberId = _readable.readString(length); } } if (_version >= 4) { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { this.groupInstanceId = null; } else if (length > 0x7fff) { throw new RuntimeException("string field groupInstanceId had invalid length " + length); } else { this.groupInstanceId = _readable.readString(length); } } else { this.groupInstanceId = null; } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field clientId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field clientId had invalid length " + length); } else { this.clientId = _readable.readString(length); } } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field clientHost was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field clientHost had invalid length " + length); } else { this.clientHost = _readable.readString(length); } } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readInt(); } if (length < 0) { throw new RuntimeException("non-nullable field memberMetadata was serialized as null"); } else { byte[] newBytes = _readable.readArray(length); this.memberMetadata = newBytes; } } { int length; if (_version >= 5) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readInt(); } if (length < 0) { throw new RuntimeException("non-nullable field memberAssignment was serialized as null"); } else { byte[] newBytes = _readable.readArray(length); this.memberAssignment = newBytes; } } this._unknownTaggedFields = null; if (_version >= 5) { 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(memberId); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 4) { if (groupInstanceId == null) { if (_version >= 5) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(groupInstanceId); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } } { byte[] _stringBytes = _cache.getSerializedValue(clientId); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(clientHost); if (_version >= 5) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 5) { _writable.writeUnsignedVarint(memberMetadata.length + 1); } else { _writable.writeInt(memberMetadata.length); } _writable.writeByteArray(memberMetadata); if (_version >= 5) { _writable.writeUnsignedVarint(memberAssignment.length + 1); } else { _writable.writeInt(memberAssignment.length); } _writable.writeByteArray(memberAssignment); RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); if (_version >= 5) { _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 > 5) { throw new UnsupportedVersionException("Can't size version " + _version + " of DescribedGroupMember"); } { 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); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } if (_version >= 4) { if (groupInstanceId == null) { if (_version >= 5) { _size.addBytes(1); } else { _size.addBytes(2); } } else { byte[] _stringBytes = groupInstanceId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'groupInstanceId' field is too long to be serialized"); } _cache.cacheSerializedValue(groupInstanceId, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } } { byte[] _stringBytes = clientId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'clientId' field is too long to be serialized"); } _cache.cacheSerializedValue(clientId, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { byte[] _stringBytes = clientHost.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'clientHost' field is too long to be serialized"); } _cache.cacheSerializedValue(clientHost, _stringBytes); if (_version >= 5) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { _size.addBytes(memberMetadata.length); if (_version >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(memberMetadata.length + 1)); } else { _size.addBytes(4); } } { _size.addBytes(memberAssignment.length); if (_version >= 5) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(memberAssignment.length + 1)); } else { _size.addBytes(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()); } } if (_version >= 5) { _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 DescribedGroupMember)) return false; DescribedGroupMember other = (DescribedGroupMember) obj; if (this.memberId == null) { if (other.memberId != null) return false; } else { if (!this.memberId.equals(other.memberId)) return false; } if (this.groupInstanceId == null) { if (other.groupInstanceId != null) return false; } else { if (!this.groupInstanceId.equals(other.groupInstanceId)) return false; } if (this.clientId == null) { if (other.clientId != null) return false; } else { if (!this.clientId.equals(other.clientId)) return false; } if (this.clientHost == null) { if (other.clientHost != null) return false; } else { if (!this.clientHost.equals(other.clientHost)) return false; } if (!Arrays.equals(this.memberMetadata, other.memberMetadata)) return false; if (!Arrays.equals(this.memberAssignment, other.memberAssignment)) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (memberId == null ? 0 : memberId.hashCode()); hashCode = 31 * hashCode + (groupInstanceId == null ? 0 : groupInstanceId.hashCode()); hashCode = 31 * hashCode + (clientId == null ? 0 : clientId.hashCode()); hashCode = 31 * hashCode + (clientHost == null ? 0 : clientHost.hashCode()); hashCode = 31 * hashCode + Arrays.hashCode(memberMetadata); hashCode = 31 * hashCode + Arrays.hashCode(memberAssignment); return hashCode; } @Override public DescribedGroupMember duplicate() { DescribedGroupMember _duplicate = new DescribedGroupMember(); _duplicate.memberId = memberId; if (groupInstanceId == null) { _duplicate.groupInstanceId = null; } else { _duplicate.groupInstanceId = groupInstanceId; } _duplicate.clientId = clientId; _duplicate.clientHost = clientHost; _duplicate.memberMetadata = MessageUtil.duplicate(memberMetadata); _duplicate.memberAssignment = MessageUtil.duplicate(memberAssignment); return _duplicate; } @Override public String toString() { return "DescribedGroupMember(" + "memberId=" + ((memberId == null) ? "null" : "'" + memberId.toString() + "'") + ", groupInstanceId=" + ((groupInstanceId == null) ? "null" : "'" + groupInstanceId.toString() + "'") + ", clientId=" + ((clientId == null) ? "null" : "'" + clientId.toString() + "'") + ", clientHost=" + ((clientHost == null) ? "null" : "'" + clientHost.toString() + "'") + ", memberMetadata=" + Arrays.toString(memberMetadata) + ", memberAssignment=" + Arrays.toString(memberAssignment) + ")"; } public String memberId() { return this.memberId; } public String groupInstanceId() { return this.groupInstanceId; } public String clientId() { return this.clientId; } public String clientHost() { return this.clientHost; } public byte[] memberMetadata() { return this.memberMetadata; } public byte[] memberAssignment() { return this.memberAssignment; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribedGroupMember setMemberId(String v) { this.memberId = v; return this; } public DescribedGroupMember setGroupInstanceId(String v) { this.groupInstanceId = v; return this; } public DescribedGroupMember setClientId(String v) { this.clientId = v; return this; } public DescribedGroupMember setClientHost(String v) { this.clientHost = v; return this; } public DescribedGroupMember setMemberMetadata(byte[] v) { this.memberMetadata = v; return this; } public DescribedGroupMember setMemberAssignment(byte[] v) { this.memberAssignment = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeGroupsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BinaryNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import java.util.Arrays; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeGroupsResponseData.*; public class DescribeGroupsResponseDataJsonConverter { public static DescribeGroupsResponseData read(JsonNode _node, short _version) { DescribeGroupsResponseData _object = new DescribeGroupsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { if (_version >= 1) { throw new RuntimeException("DescribeGroupsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = 0; } } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeGroupsResponseData"); } JsonNode _groupsNode = _node.get("groups"); if (_groupsNode == null) { throw new RuntimeException("DescribeGroupsResponseData: unable to locate field 'groups', which is mandatory in version " + _version); } else { if (!_groupsNode.isArray()) { throw new RuntimeException("DescribeGroupsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribedGroup> _collection = new ArrayList<DescribedGroup>(_groupsNode.size()); _object.groups = _collection; for (JsonNode _element : _groupsNode) { _collection.add(DescribedGroupJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeGroupsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_version >= 1) { _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); } ArrayNode _groupsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribedGroup _element : _object.groups) { _groupsArray.add(DescribedGroupJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("groups", _groupsArray); return _node; } public static JsonNode write(DescribeGroupsResponseData _object, short _version) { return write(_object, _version, true); } public static class DescribedGroupJsonConverter { public static DescribedGroup read(JsonNode _node, short _version) { DescribedGroup _object = new DescribedGroup(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribedGroup: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribedGroup"); } JsonNode _groupIdNode = _node.get("groupId"); if (_groupIdNode == null) { throw new RuntimeException("DescribedGroup: unable to locate field 'groupId', which is mandatory in version " + _version); } else { if (!_groupIdNode.isTextual()) { throw new RuntimeException("DescribedGroup expected a string type, but got " + _node.getNodeType()); } _object.groupId = _groupIdNode.asText(); } JsonNode _groupStateNode = _node.get("groupState"); if (_groupStateNode == null) { throw new RuntimeException("DescribedGroup: unable to locate field 'groupState', which is mandatory in version " + _version); } else { if (!_groupStateNode.isTextual()) { throw new RuntimeException("DescribedGroup expected a string type, but got " + _node.getNodeType()); } _object.groupState = _groupStateNode.asText(); } JsonNode _protocolTypeNode = _node.get("protocolType"); if (_protocolTypeNode == null) { throw new RuntimeException("DescribedGroup: unable to locate field 'protocolType', which is mandatory in version " + _version); } else { if (!_protocolTypeNode.isTextual()) { throw new RuntimeException("DescribedGroup expected a string type, but got " + _node.getNodeType()); } _object.protocolType = _protocolTypeNode.asText(); } JsonNode _protocolDataNode = _node.get("protocolData"); if (_protocolDataNode == null) { throw new RuntimeException("DescribedGroup: unable to locate field 'protocolData', which is mandatory in version " + _version); } else { if (!_protocolDataNode.isTextual()) { throw new RuntimeException("DescribedGroup expected a string type, but got " + _node.getNodeType()); } _object.protocolData = _protocolDataNode.asText(); } JsonNode _membersNode = _node.get("members"); if (_membersNode == null) { throw new RuntimeException("DescribedGroup: unable to locate field 'members', which is mandatory in version " + _version); } else { if (!_membersNode.isArray()) { throw new RuntimeException("DescribedGroup expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribedGroupMember> _collection = new ArrayList<DescribedGroupMember>(_membersNode.size()); _object.members = _collection; for (JsonNode _element : _membersNode) { _collection.add(DescribedGroupMemberJsonConverter.read(_element, _version)); } } JsonNode _authorizedOperationsNode = _node.get("authorizedOperations"); if (_authorizedOperationsNode == null) { if (_version >= 3) { throw new RuntimeException("DescribedGroup: unable to locate field 'authorizedOperations', which is mandatory in version " + _version); } else { _object.authorizedOperations = -2147483648; } } else { _object.authorizedOperations = MessageUtil.jsonNodeToInt(_authorizedOperationsNode, "DescribedGroup"); } return _object; } public static JsonNode write(DescribedGroup _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); _node.set("groupId", new TextNode(_object.groupId)); _node.set("groupState", new TextNode(_object.groupState)); _node.set("protocolType", new TextNode(_object.protocolType)); _node.set("protocolData", new TextNode(_object.protocolData)); ArrayNode _membersArray = new ArrayNode(JsonNodeFactory.instance); for (DescribedGroupMember _element : _object.members) { _membersArray.add(DescribedGroupMemberJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("members", _membersArray); if (_version >= 3) { _node.set("authorizedOperations", new IntNode(_object.authorizedOperations)); } else { if (_object.authorizedOperations != -2147483648) { throw new UnsupportedVersionException("Attempted to write a non-default authorizedOperations at version " + _version); } } return _node; } public static JsonNode write(DescribedGroup _object, short _version) { return write(_object, _version, true); } } public static class DescribedGroupMemberJsonConverter { public static DescribedGroupMember read(JsonNode _node, short _version) { DescribedGroupMember _object = new DescribedGroupMember(); JsonNode _memberIdNode = _node.get("memberId"); if (_memberIdNode == null) { throw new RuntimeException("DescribedGroupMember: unable to locate field 'memberId', which is mandatory in version " + _version); } else { if (!_memberIdNode.isTextual()) { throw new RuntimeException("DescribedGroupMember expected a string type, but got " + _node.getNodeType()); } _object.memberId = _memberIdNode.asText(); } JsonNode _groupInstanceIdNode = _node.get("groupInstanceId"); if (_groupInstanceIdNode == null) { if (_version >= 4) { throw new RuntimeException("DescribedGroupMember: unable to locate field 'groupInstanceId', which is mandatory in version " + _version); } else { _object.groupInstanceId = null; } } else { if (_groupInstanceIdNode.isNull()) { _object.groupInstanceId = null; } else { if (!_groupInstanceIdNode.isTextual()) { throw new RuntimeException("DescribedGroupMember expected a string type, but got " + _node.getNodeType()); } _object.groupInstanceId = _groupInstanceIdNode.asText(); } } JsonNode _clientIdNode = _node.get("clientId"); if (_clientIdNode == null) { throw new RuntimeException("DescribedGroupMember: unable to locate field 'clientId', which is mandatory in version " + _version); } else { if (!_clientIdNode.isTextual()) { throw new RuntimeException("DescribedGroupMember expected a string type, but got " + _node.getNodeType()); } _object.clientId = _clientIdNode.asText(); } JsonNode _clientHostNode = _node.get("clientHost"); if (_clientHostNode == null) { throw new RuntimeException("DescribedGroupMember: unable to locate field 'clientHost', which is mandatory in version " + _version); } else { if (!_clientHostNode.isTextual()) { throw new RuntimeException("DescribedGroupMember expected a string type, but got " + _node.getNodeType()); } _object.clientHost = _clientHostNode.asText(); } JsonNode _memberMetadataNode = _node.get("memberMetadata"); if (_memberMetadataNode == null) { throw new RuntimeException("DescribedGroupMember: unable to locate field 'memberMetadata', which is mandatory in version " + _version); } else { _object.memberMetadata = MessageUtil.jsonNodeToBinary(_memberMetadataNode, "DescribedGroupMember"); } JsonNode _memberAssignmentNode = _node.get("memberAssignment"); if (_memberAssignmentNode == null) { throw new RuntimeException("DescribedGroupMember: unable to locate field 'memberAssignment', which is mandatory in version " + _version); } else { _object.memberAssignment = MessageUtil.jsonNodeToBinary(_memberAssignmentNode, "DescribedGroupMember"); } return _object; } public static JsonNode write(DescribedGroupMember _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("memberId", new TextNode(_object.memberId)); if (_version >= 4) { if (_object.groupInstanceId == null) { _node.set("groupInstanceId", NullNode.instance); } else { _node.set("groupInstanceId", new TextNode(_object.groupInstanceId)); } } _node.set("clientId", new TextNode(_object.clientId)); _node.set("clientHost", new TextNode(_object.clientHost)); _node.set("memberMetadata", new BinaryNode(Arrays.copyOf(_object.memberMetadata, _object.memberMetadata.length))); _node.set("memberAssignment", new BinaryNode(Arrays.copyOf(_object.memberAssignment, _object.memberAssignment.length))); return _node; } public static JsonNode write(DescribedGroupMember _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeLogDirsRequestData.java
/* * 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.Iterator; 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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class DescribeLogDirsRequestData implements ApiMessage { DescribableLogDirTopicCollection topics; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topics", ArrayOf.nullable(DescribableLogDirTopic.SCHEMA_0), "Each topic that we want to describe log directories for, or null for all topics.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("topics", CompactArrayOf.nullable(DescribableLogDirTopic.SCHEMA_2), "Each topic that we want to describe log directories for, or null for all topics."), 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 DescribeLogDirsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeLogDirsRequestData() { this.topics = new DescribableLogDirTopicCollection(0); } @Override public short apiKey() { return 35; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 4; } @Override public void read(Readable _readable, short _version) { { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.topics = 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."); } DescribableLogDirTopicCollection newCollection = new DescribableLogDirTopicCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribableLogDirTopic(_readable, _version)); } this.topics = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { this.topics = 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."); } DescribableLogDirTopicCollection newCollection = new DescribableLogDirTopicCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribableLogDirTopic(_readable, _version)); } this.topics = 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; if (_version >= 2) { if (topics == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(topics.size() + 1); for (DescribableLogDirTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } } else { if (topics == null) { _writable.writeInt(-1); } else { _writable.writeInt(topics.size()); for (DescribableLogDirTopic topicsElement : topics) { topicsElement.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; if (topics == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(4); } } else { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); } else { _size.addBytes(4); } for (DescribableLogDirTopic topicsElement : topics) { topicsElement.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 DescribeLogDirsRequestData)) return false; DescribeLogDirsRequestData other = (DescribeLogDirsRequestData) obj; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public DescribeLogDirsRequestData duplicate() { DescribeLogDirsRequestData _duplicate = new DescribeLogDirsRequestData(); if (topics == null) { _duplicate.topics = null; } else { DescribableLogDirTopicCollection newTopics = new DescribableLogDirTopicCollection(topics.size()); for (DescribableLogDirTopic _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; } return _duplicate; } @Override public String toString() { return "DescribeLogDirsRequestData(" + "topics=" + ((topics == null) ? "null" : MessageUtil.deepToString(topics.iterator())) + ")"; } public DescribableLogDirTopicCollection topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeLogDirsRequestData setTopics(DescribableLogDirTopicCollection v) { this.topics = v; return this; } public static class DescribableLogDirTopic implements Message, ImplicitLinkedHashMultiCollection.Element { String topic; List<Integer> partitions; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("topic", Type.STRING, "The topic name"), new Field("partitions", new ArrayOf(Type.INT32), "The partition indexes.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("topic", Type.COMPACT_STRING, "The topic name"), new Field("partitions", new CompactArrayOf(Type.INT32), "The partition indexes."), 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 DescribableLogDirTopic(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public DescribableLogDirTopic() { this.topic = ""; this.partitions = new ArrayList<Integer>(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @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 DescribableLogDirTopic"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field topic was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topic had invalid length " + length); } else { this.topic = _readable.readString(length); } } { int arrayLength; if (_version >= 2) { arrayLength = _readable.readUnsignedVarint() - 1; } else { arrayLength = _readable.readInt(); } 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<Integer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(_readable.readInt()); } this.partitions = 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; { byte[] _stringBytes = _cache.getSerializedValue(topic); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(partitions.size() + 1); } else { _writable.writeInt(partitions.size()); } for (Integer partitionsElement : partitions) { _writable.writeInt(partitionsElement); } 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 DescribableLogDirTopic"); } { byte[] _stringBytes = topic.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'topic' field is too long to be serialized"); } _cache.cacheSerializedValue(topic, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1)); } else { _size.addBytes(4); } _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()); } } 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 elementKeysAreEqual(Object obj) { if (!(obj instanceof DescribableLogDirTopic)) return false; DescribableLogDirTopic other = (DescribableLogDirTopic) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof DescribableLogDirTopic)) return false; DescribableLogDirTopic other = (DescribableLogDirTopic) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) 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 + (topic == null ? 0 : topic.hashCode()); return hashCode; } @Override public DescribableLogDirTopic duplicate() { DescribableLogDirTopic _duplicate = new DescribableLogDirTopic(); _duplicate.topic = topic; ArrayList<Integer> newPartitions = new ArrayList<Integer>(partitions.size()); for (Integer _element : partitions) { newPartitions.add(_element); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "DescribableLogDirTopic(" + "topic=" + ((topic == null) ? "null" : "'" + topic.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topic() { return this.topic; } public List<Integer> partitions() { return this.partitions; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribableLogDirTopic setTopic(String v) { this.topic = v; return this; } public DescribableLogDirTopic setPartitions(List<Integer> v) { this.partitions = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class DescribableLogDirTopicCollection extends ImplicitLinkedHashMultiCollection<DescribableLogDirTopic> { public DescribableLogDirTopicCollection() { super(); } public DescribableLogDirTopicCollection(int expectedNumElements) { super(expectedNumElements); } public DescribableLogDirTopicCollection(Iterator<DescribableLogDirTopic> iterator) { super(iterator); } public DescribableLogDirTopic find(String topic) { DescribableLogDirTopic _key = new DescribableLogDirTopic(); _key.setTopic(topic); return find(_key); } public List<DescribableLogDirTopic> findAll(String topic) { DescribableLogDirTopic _key = new DescribableLogDirTopic(); _key.setTopic(topic); return findAll(_key); } public DescribableLogDirTopicCollection duplicate() { DescribableLogDirTopicCollection _duplicate = new DescribableLogDirTopicCollection(size()); for (DescribableLogDirTopic _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeLogDirsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeLogDirsRequestData.*; public class DescribeLogDirsRequestDataJsonConverter { public static DescribeLogDirsRequestData read(JsonNode _node, short _version) { DescribeLogDirsRequestData _object = new DescribeLogDirsRequestData(); JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("DescribeLogDirsRequestData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (_topicsNode.isNull()) { _object.topics = null; } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DescribeLogDirsRequestData expected a JSON array, but got " + _node.getNodeType()); } DescribableLogDirTopicCollection _collection = new DescribableLogDirTopicCollection(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(DescribableLogDirTopicJsonConverter.read(_element, _version)); } } } return _object; } public static JsonNode write(DescribeLogDirsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_object.topics == null) { _node.set("topics", NullNode.instance); } else { ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribableLogDirTopic _element : _object.topics) { _topicsArray.add(DescribableLogDirTopicJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); } return _node; } public static JsonNode write(DescribeLogDirsRequestData _object, short _version) { return write(_object, _version, true); } public static class DescribableLogDirTopicJsonConverter { public static DescribableLogDirTopic read(JsonNode _node, short _version) { DescribableLogDirTopic _object = new DescribableLogDirTopic(); JsonNode _topicNode = _node.get("topic"); if (_topicNode == null) { throw new RuntimeException("DescribableLogDirTopic: unable to locate field 'topic', which is mandatory in version " + _version); } else { if (!_topicNode.isTextual()) { throw new RuntimeException("DescribableLogDirTopic expected a string type, but got " + _node.getNodeType()); } _object.topic = _topicNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("DescribableLogDirTopic: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("DescribableLogDirTopic expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "DescribableLogDirTopic element")); } } return _object; } public static JsonNode write(DescribableLogDirTopic _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topic", new TextNode(_object.topic)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.partitions) { _partitionsArray.add(new IntNode(_element)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(DescribableLogDirTopic _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeLogDirsResponseData.java
/* * 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 DescribeLogDirsResponseData implements ApiMessage { int throttleTimeMs; short errorCode; List<DescribeLogDirsResult> results; private List<RawTaggedField> _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("results", new ArrayOf(DescribeLogDirsResult.SCHEMA_0), "The log directories.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = 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("results", new CompactArrayOf(DescribeLogDirsResult.SCHEMA_2), "The log directories."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = 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 error code, or 0 if there was no error."), new Field("results", new CompactArrayOf(DescribeLogDirsResult.SCHEMA_2), "The log directories."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_4 = 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 error code, or 0 if there was no error."), new Field("results", new CompactArrayOf(DescribeLogDirsResult.SCHEMA_4), "The log directories."), TaggedFieldsSection.of( ) ); 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 DescribeLogDirsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeLogDirsResponseData() { this.throttleTimeMs = 0; this.errorCode = (short) 0; this.results = new ArrayList<DescribeLogDirsResult>(0); } @Override public short apiKey() { return 35; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 4; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); if (_version >= 3) { this.errorCode = _readable.readShort(); } else { this.errorCode = (short) 0; } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<DescribeLogDirsResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeLogDirsResult(_readable, _version)); } this.results = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<DescribeLogDirsResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeLogDirsResult(_readable, _version)); } this.results = 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.writeInt(throttleTimeMs); if (_version >= 3) { _writable.writeShort(errorCode); } if (_version >= 2) { _writable.writeUnsignedVarint(results.size() + 1); for (DescribeLogDirsResult resultsElement : results) { resultsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(results.size()); for (DescribeLogDirsResult resultsElement : results) { resultsElement.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(4); if (_version >= 3) { _size.addBytes(2); } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(results.size() + 1)); } else { _size.addBytes(4); } for (DescribeLogDirsResult resultsElement : results) { resultsElement.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 DescribeLogDirsResponseData)) return false; DescribeLogDirsResponseData other = (DescribeLogDirsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (errorCode != other.errorCode) return false; if (this.results == null) { if (other.results != null) return false; } else { if (!this.results.equals(other.results)) 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 + (results == null ? 0 : results.hashCode()); return hashCode; } @Override public DescribeLogDirsResponseData duplicate() { DescribeLogDirsResponseData _duplicate = new DescribeLogDirsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; _duplicate.errorCode = errorCode; ArrayList<DescribeLogDirsResult> newResults = new ArrayList<DescribeLogDirsResult>(results.size()); for (DescribeLogDirsResult _element : results) { newResults.add(_element.duplicate()); } _duplicate.results = newResults; return _duplicate; } @Override public String toString() { return "DescribeLogDirsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", errorCode=" + errorCode + ", results=" + MessageUtil.deepToString(results.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public short errorCode() { return this.errorCode; } public List<DescribeLogDirsResult> results() { return this.results; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeLogDirsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeLogDirsResponseData setErrorCode(short v) { this.errorCode = v; return this; } public DescribeLogDirsResponseData setResults(List<DescribeLogDirsResult> v) { this.results = v; return this; } public static class DescribeLogDirsResult implements Message { short errorCode; String logDir; List<DescribeLogDirsTopic> topics; long totalBytes; long usableBytes; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("log_dir", Type.STRING, "The absolute log directory path."), new Field("topics", new ArrayOf(DescribeLogDirsTopic.SCHEMA_0), "Each topic.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("log_dir", Type.COMPACT_STRING, "The absolute log directory path."), new Field("topics", new CompactArrayOf(DescribeLogDirsTopic.SCHEMA_2), "Each topic."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_3 = SCHEMA_2; public static final Schema SCHEMA_4 = new Schema( new Field("error_code", Type.INT16, "The error code, or 0 if there was no error."), new Field("log_dir", Type.COMPACT_STRING, "The absolute log directory path."), new Field("topics", new CompactArrayOf(DescribeLogDirsTopic.SCHEMA_2), "Each topic."), new Field("total_bytes", Type.INT64, "The total size in bytes of the volume the log directory is in."), new Field("usable_bytes", Type.INT64, "The usable size in bytes of the volume the log directory is in."), TaggedFieldsSection.of( ) ); 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 DescribeLogDirsResult(Readable _readable, short _version) { read(_readable, _version); } public DescribeLogDirsResult() { this.errorCode = (short) 0; this.logDir = ""; this.topics = new ArrayList<DescribeLogDirsTopic>(0); this.totalBytes = -1L; this.usableBytes = -1L; } @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 DescribeLogDirsResult"); } this.errorCode = _readable.readShort(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field logDir was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field logDir had invalid length " + length); } else { this.logDir = _readable.readString(length); } } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<DescribeLogDirsTopic> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeLogDirsTopic(_readable, _version)); } this.topics = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<DescribeLogDirsTopic> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeLogDirsTopic(_readable, _version)); } this.topics = newCollection; } } } if (_version >= 4) { this.totalBytes = _readable.readLong(); } else { this.totalBytes = -1L; } if (_version >= 4) { this.usableBytes = _readable.readLong(); } else { this.usableBytes = -1L; } 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); { byte[] _stringBytes = _cache.getSerializedValue(logDir); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(topics.size() + 1); for (DescribeLogDirsTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(topics.size()); for (DescribeLogDirsTopic topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } } if (_version >= 4) { _writable.writeLong(totalBytes); } if (_version >= 4) { _writable.writeLong(usableBytes); } 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 DescribeLogDirsResult"); } _size.addBytes(2); { byte[] _stringBytes = logDir.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'logDir' field is too long to be serialized"); } _cache.cacheSerializedValue(logDir, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); } else { _size.addBytes(4); } for (DescribeLogDirsTopic topicsElement : topics) { topicsElement.addSize(_size, _cache, _version); } } if (_version >= 4) { _size.addBytes(8); } if (_version >= 4) { _size.addBytes(8); } 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 DescribeLogDirsResult)) return false; DescribeLogDirsResult other = (DescribeLogDirsResult) obj; if (errorCode != other.errorCode) return false; if (this.logDir == null) { if (other.logDir != null) return false; } else { if (!this.logDir.equals(other.logDir)) return false; } if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } if (totalBytes != other.totalBytes) return false; if (usableBytes != other.usableBytes) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (logDir == null ? 0 : logDir.hashCode()); hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); hashCode = 31 * hashCode + ((int) (totalBytes >> 32) ^ (int) totalBytes); hashCode = 31 * hashCode + ((int) (usableBytes >> 32) ^ (int) usableBytes); return hashCode; } @Override public DescribeLogDirsResult duplicate() { DescribeLogDirsResult _duplicate = new DescribeLogDirsResult(); _duplicate.errorCode = errorCode; _duplicate.logDir = logDir; ArrayList<DescribeLogDirsTopic> newTopics = new ArrayList<DescribeLogDirsTopic>(topics.size()); for (DescribeLogDirsTopic _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; _duplicate.totalBytes = totalBytes; _duplicate.usableBytes = usableBytes; return _duplicate; } @Override public String toString() { return "DescribeLogDirsResult(" + "errorCode=" + errorCode + ", logDir=" + ((logDir == null) ? "null" : "'" + logDir.toString() + "'") + ", topics=" + MessageUtil.deepToString(topics.iterator()) + ", totalBytes=" + totalBytes + ", usableBytes=" + usableBytes + ")"; } public short errorCode() { return this.errorCode; } public String logDir() { return this.logDir; } public List<DescribeLogDirsTopic> topics() { return this.topics; } public long totalBytes() { return this.totalBytes; } public long usableBytes() { return this.usableBytes; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeLogDirsResult setErrorCode(short v) { this.errorCode = v; return this; } public DescribeLogDirsResult setLogDir(String v) { this.logDir = v; return this; } public DescribeLogDirsResult setTopics(List<DescribeLogDirsTopic> v) { this.topics = v; return this; } public DescribeLogDirsResult setTotalBytes(long v) { this.totalBytes = v; return this; } public DescribeLogDirsResult setUsableBytes(long v) { this.usableBytes = v; return this; } } public static class DescribeLogDirsTopic implements Message { String name; List<DescribeLogDirsPartition> partitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.STRING, "The topic name."), new Field("partitions", new ArrayOf(DescribeLogDirsPartition.SCHEMA_0), "") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("partitions", new CompactArrayOf(DescribeLogDirsPartition.SCHEMA_2), ""), 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 DescribeLogDirsTopic(Readable _readable, short _version) { read(_readable, _version); } public DescribeLogDirsTopic() { this.name = ""; this.partitions = new ArrayList<DescribeLogDirsPartition>(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 DescribeLogDirsTopic"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { if (_version >= 2) { 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<DescribeLogDirsPartition> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeLogDirsPartition(_readable, _version)); } this.partitions = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); 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<DescribeLogDirsPartition> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeLogDirsPartition(_readable, _version)); } this.partitions = 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; { byte[] _stringBytes = _cache.getSerializedValue(name); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(partitions.size() + 1); for (DescribeLogDirsPartition partitionsElement : partitions) { partitionsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(partitions.size()); for (DescribeLogDirsPartition partitionsElement : partitions) { partitionsElement.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; if (_version > 4) { throw new UnsupportedVersionException("Can't size version " + _version + " of DescribeLogDirsTopic"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1)); } else { _size.addBytes(4); } for (DescribeLogDirsPartition partitionsElement : partitions) { partitionsElement.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 DescribeLogDirsTopic)) return false; DescribeLogDirsTopic other = (DescribeLogDirsTopic) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) 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 + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + (partitions == null ? 0 : partitions.hashCode()); return hashCode; } @Override public DescribeLogDirsTopic duplicate() { DescribeLogDirsTopic _duplicate = new DescribeLogDirsTopic(); _duplicate.name = name; ArrayList<DescribeLogDirsPartition> newPartitions = new ArrayList<DescribeLogDirsPartition>(partitions.size()); for (DescribeLogDirsPartition _element : partitions) { newPartitions.add(_element.duplicate()); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "DescribeLogDirsTopic(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String name() { return this.name; } public List<DescribeLogDirsPartition> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeLogDirsTopic setName(String v) { this.name = v; return this; } public DescribeLogDirsTopic setPartitions(List<DescribeLogDirsPartition> v) { this.partitions = v; return this; } } public static class DescribeLogDirsPartition implements Message { int partitionIndex; long partitionSize; long offsetLag; boolean isFutureKey; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("partition_size", Type.INT64, "The size of the log segments in this partition in bytes."), new Field("offset_lag", Type.INT64, "The lag of the log's LEO w.r.t. partition's HW (if it is the current log for the partition) or current replica's LEO (if it is the future log for the partition)"), new Field("is_future_key", Type.BOOLEAN, "True if this log is created by AlterReplicaLogDirsRequest and will replace the current log of the replica in the future.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("partition_size", Type.INT64, "The size of the log segments in this partition in bytes."), new Field("offset_lag", Type.INT64, "The lag of the log's LEO w.r.t. partition's HW (if it is the current log for the partition) or current replica's LEO (if it is the future log for the partition)"), new Field("is_future_key", Type.BOOLEAN, "True if this log is created by AlterReplicaLogDirsRequest and will replace the current log of the replica in the future."), 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 DescribeLogDirsPartition(Readable _readable, short _version) { read(_readable, _version); } public DescribeLogDirsPartition() { this.partitionIndex = 0; this.partitionSize = 0L; this.offsetLag = 0L; this.isFutureKey = false; } @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 DescribeLogDirsPartition"); } this.partitionIndex = _readable.readInt(); this.partitionSize = _readable.readLong(); this.offsetLag = _readable.readLong(); this.isFutureKey = _readable.readByte() != 0; 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.writeInt(partitionIndex); _writable.writeLong(partitionSize); _writable.writeLong(offsetLag); _writable.writeByte(isFutureKey ? (byte) 1 : (byte) 0); 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 DescribeLogDirsPartition"); } _size.addBytes(4); _size.addBytes(8); _size.addBytes(8); _size.addBytes(1); 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 DescribeLogDirsPartition)) return false; DescribeLogDirsPartition other = (DescribeLogDirsPartition) obj; if (partitionIndex != other.partitionIndex) return false; if (partitionSize != other.partitionSize) return false; if (offsetLag != other.offsetLag) return false; if (isFutureKey != other.isFutureKey) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; hashCode = 31 * hashCode + ((int) (partitionSize >> 32) ^ (int) partitionSize); hashCode = 31 * hashCode + ((int) (offsetLag >> 32) ^ (int) offsetLag); hashCode = 31 * hashCode + (isFutureKey ? 1231 : 1237); return hashCode; } @Override public DescribeLogDirsPartition duplicate() { DescribeLogDirsPartition _duplicate = new DescribeLogDirsPartition(); _duplicate.partitionIndex = partitionIndex; _duplicate.partitionSize = partitionSize; _duplicate.offsetLag = offsetLag; _duplicate.isFutureKey = isFutureKey; return _duplicate; } @Override public String toString() { return "DescribeLogDirsPartition(" + "partitionIndex=" + partitionIndex + ", partitionSize=" + partitionSize + ", offsetLag=" + offsetLag + ", isFutureKey=" + (isFutureKey ? "true" : "false") + ")"; } public int partitionIndex() { return this.partitionIndex; } public long partitionSize() { return this.partitionSize; } public long offsetLag() { return this.offsetLag; } public boolean isFutureKey() { return this.isFutureKey; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeLogDirsPartition setPartitionIndex(int v) { this.partitionIndex = v; return this; } public DescribeLogDirsPartition setPartitionSize(long v) { this.partitionSize = v; return this; } public DescribeLogDirsPartition setOffsetLag(long v) { this.offsetLag = v; return this; } public DescribeLogDirsPartition setIsFutureKey(boolean v) { this.isFutureKey = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeLogDirsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeLogDirsResponseData.*; public class DescribeLogDirsResponseDataJsonConverter { public static DescribeLogDirsResponseData read(JsonNode _node, short _version) { DescribeLogDirsResponseData _object = new DescribeLogDirsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeLogDirsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeLogDirsResponseData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { if (_version >= 3) { throw new RuntimeException("DescribeLogDirsResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = (short) 0; } } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeLogDirsResponseData"); } JsonNode _resultsNode = _node.get("results"); if (_resultsNode == null) { throw new RuntimeException("DescribeLogDirsResponseData: unable to locate field 'results', which is mandatory in version " + _version); } else { if (!_resultsNode.isArray()) { throw new RuntimeException("DescribeLogDirsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeLogDirsResult> _collection = new ArrayList<DescribeLogDirsResult>(_resultsNode.size()); _object.results = _collection; for (JsonNode _element : _resultsNode) { _collection.add(DescribeLogDirsResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeLogDirsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); if (_version >= 3) { _node.set("errorCode", new ShortNode(_object.errorCode)); } ArrayNode _resultsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeLogDirsResult _element : _object.results) { _resultsArray.add(DescribeLogDirsResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("results", _resultsArray); return _node; } public static JsonNode write(DescribeLogDirsResponseData _object, short _version) { return write(_object, _version, true); } public static class DescribeLogDirsPartitionJsonConverter { public static DescribeLogDirsPartition read(JsonNode _node, short _version) { DescribeLogDirsPartition _object = new DescribeLogDirsPartition(); JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("DescribeLogDirsPartition: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "DescribeLogDirsPartition"); } JsonNode _partitionSizeNode = _node.get("partitionSize"); if (_partitionSizeNode == null) { throw new RuntimeException("DescribeLogDirsPartition: unable to locate field 'partitionSize', which is mandatory in version " + _version); } else { _object.partitionSize = MessageUtil.jsonNodeToLong(_partitionSizeNode, "DescribeLogDirsPartition"); } JsonNode _offsetLagNode = _node.get("offsetLag"); if (_offsetLagNode == null) { throw new RuntimeException("DescribeLogDirsPartition: unable to locate field 'offsetLag', which is mandatory in version " + _version); } else { _object.offsetLag = MessageUtil.jsonNodeToLong(_offsetLagNode, "DescribeLogDirsPartition"); } JsonNode _isFutureKeyNode = _node.get("isFutureKey"); if (_isFutureKeyNode == null) { throw new RuntimeException("DescribeLogDirsPartition: unable to locate field 'isFutureKey', which is mandatory in version " + _version); } else { if (!_isFutureKeyNode.isBoolean()) { throw new RuntimeException("DescribeLogDirsPartition expected Boolean type, but got " + _node.getNodeType()); } _object.isFutureKey = _isFutureKeyNode.asBoolean(); } return _object; } public static JsonNode write(DescribeLogDirsPartition _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); _node.set("partitionSize", new LongNode(_object.partitionSize)); _node.set("offsetLag", new LongNode(_object.offsetLag)); _node.set("isFutureKey", BooleanNode.valueOf(_object.isFutureKey)); return _node; } public static JsonNode write(DescribeLogDirsPartition _object, short _version) { return write(_object, _version, true); } } public static class DescribeLogDirsResultJsonConverter { public static DescribeLogDirsResult read(JsonNode _node, short _version) { DescribeLogDirsResult _object = new DescribeLogDirsResult(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeLogDirsResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeLogDirsResult"); } JsonNode _logDirNode = _node.get("logDir"); if (_logDirNode == null) { throw new RuntimeException("DescribeLogDirsResult: unable to locate field 'logDir', which is mandatory in version " + _version); } else { if (!_logDirNode.isTextual()) { throw new RuntimeException("DescribeLogDirsResult expected a string type, but got " + _node.getNodeType()); } _object.logDir = _logDirNode.asText(); } JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("DescribeLogDirsResult: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DescribeLogDirsResult expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeLogDirsTopic> _collection = new ArrayList<DescribeLogDirsTopic>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(DescribeLogDirsTopicJsonConverter.read(_element, _version)); } } JsonNode _totalBytesNode = _node.get("totalBytes"); if (_totalBytesNode == null) { if (_version >= 4) { throw new RuntimeException("DescribeLogDirsResult: unable to locate field 'totalBytes', which is mandatory in version " + _version); } else { _object.totalBytes = -1L; } } else { _object.totalBytes = MessageUtil.jsonNodeToLong(_totalBytesNode, "DescribeLogDirsResult"); } JsonNode _usableBytesNode = _node.get("usableBytes"); if (_usableBytesNode == null) { if (_version >= 4) { throw new RuntimeException("DescribeLogDirsResult: unable to locate field 'usableBytes', which is mandatory in version " + _version); } else { _object.usableBytes = -1L; } } else { _object.usableBytes = MessageUtil.jsonNodeToLong(_usableBytesNode, "DescribeLogDirsResult"); } return _object; } public static JsonNode write(DescribeLogDirsResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); _node.set("logDir", new TextNode(_object.logDir)); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeLogDirsTopic _element : _object.topics) { _topicsArray.add(DescribeLogDirsTopicJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); if (_version >= 4) { _node.set("totalBytes", new LongNode(_object.totalBytes)); } if (_version >= 4) { _node.set("usableBytes", new LongNode(_object.usableBytes)); } return _node; } public static JsonNode write(DescribeLogDirsResult _object, short _version) { return write(_object, _version, true); } } public static class DescribeLogDirsTopicJsonConverter { public static DescribeLogDirsTopic read(JsonNode _node, short _version) { DescribeLogDirsTopic _object = new DescribeLogDirsTopic(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("DescribeLogDirsTopic: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("DescribeLogDirsTopic expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("DescribeLogDirsTopic: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("DescribeLogDirsTopic expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeLogDirsPartition> _collection = new ArrayList<DescribeLogDirsPartition>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(DescribeLogDirsPartitionJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeLogDirsTopic _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeLogDirsPartition _element : _object.partitions) { _partitionsArray.add(DescribeLogDirsPartitionJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(DescribeLogDirsTopic _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeProducersRequestData.java
/* * 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.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 DescribeProducersRequestData implements ApiMessage { List<TopicRequest> topics; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topics", new CompactArrayOf(TopicRequest.SCHEMA_0), ""), 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 DescribeProducersRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeProducersRequestData() { this.topics = new ArrayList<TopicRequest>(0); } @Override public short apiKey() { return 61; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<TopicRequest> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicRequest(_readable, _version)); } this.topics = 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(topics.size() + 1); for (TopicRequest topicsElement : topics) { topicsElement.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(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); for (TopicRequest topicsElement : topics) { topicsElement.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 DescribeProducersRequestData)) return false; DescribeProducersRequestData other = (DescribeProducersRequestData) obj; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public DescribeProducersRequestData duplicate() { DescribeProducersRequestData _duplicate = new DescribeProducersRequestData(); ArrayList<TopicRequest> newTopics = new ArrayList<TopicRequest>(topics.size()); for (TopicRequest _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "DescribeProducersRequestData(" + "topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public List<TopicRequest> topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeProducersRequestData setTopics(List<TopicRequest> v) { this.topics = v; return this; } public static class TopicRequest implements Message { String name; List<Integer> partitionIndexes; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name."), new Field("partition_indexes", new CompactArrayOf(Type.INT32), "The indexes of the partitions to list producers for."), 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 TopicRequest(Readable _readable, short _version) { read(_readable, _version); } public TopicRequest() { this.name = ""; this.partitionIndexes = new ArrayList<Integer>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicRequest"); } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field partitionIndexes 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<Integer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(_readable.readInt()); } this.partitionIndexes = 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; { byte[] _stringBytes = _cache.getSerializedValue(name); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeUnsignedVarint(partitionIndexes.size() + 1); for (Integer partitionIndexesElement : partitionIndexes) { _writable.writeInt(partitionIndexesElement); } 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 TopicRequest"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitionIndexes.size() + 1)); _size.addBytes(partitionIndexes.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 TopicRequest)) return false; TopicRequest other = (TopicRequest) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } if (this.partitionIndexes == null) { if (other.partitionIndexes != null) return false; } else { if (!this.partitionIndexes.equals(other.partitionIndexes)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + (partitionIndexes == null ? 0 : partitionIndexes.hashCode()); return hashCode; } @Override public TopicRequest duplicate() { TopicRequest _duplicate = new TopicRequest(); _duplicate.name = name; ArrayList<Integer> newPartitionIndexes = new ArrayList<Integer>(partitionIndexes.size()); for (Integer _element : partitionIndexes) { newPartitionIndexes.add(_element); } _duplicate.partitionIndexes = newPartitionIndexes; return _duplicate; } @Override public String toString() { return "TopicRequest(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", partitionIndexes=" + MessageUtil.deepToString(partitionIndexes.iterator()) + ")"; } public String name() { return this.name; } public List<Integer> partitionIndexes() { return this.partitionIndexes; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicRequest setName(String v) { this.name = v; return this; } public TopicRequest setPartitionIndexes(List<Integer> v) { this.partitionIndexes = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeProducersRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeProducersRequestData.*; public class DescribeProducersRequestDataJsonConverter { public static DescribeProducersRequestData read(JsonNode _node, short _version) { DescribeProducersRequestData _object = new DescribeProducersRequestData(); JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("DescribeProducersRequestData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DescribeProducersRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TopicRequest> _collection = new ArrayList<TopicRequest>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(TopicRequestJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeProducersRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicRequest _element : _object.topics) { _topicsArray.add(TopicRequestJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); return _node; } public static JsonNode write(DescribeProducersRequestData _object, short _version) { return write(_object, _version, true); } public static class TopicRequestJsonConverter { public static TopicRequest read(JsonNode _node, short _version) { TopicRequest _object = new TopicRequest(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("TopicRequest: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("TopicRequest expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _partitionIndexesNode = _node.get("partitionIndexes"); if (_partitionIndexesNode == null) { throw new RuntimeException("TopicRequest: unable to locate field 'partitionIndexes', which is mandatory in version " + _version); } else { if (!_partitionIndexesNode.isArray()) { throw new RuntimeException("TopicRequest expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_partitionIndexesNode.size()); _object.partitionIndexes = _collection; for (JsonNode _element : _partitionIndexesNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "TopicRequest element")); } } return _object; } public static JsonNode write(TopicRequest _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); ArrayNode _partitionIndexesArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.partitionIndexes) { _partitionIndexesArray.add(new IntNode(_element)); } _node.set("partitionIndexes", _partitionIndexesArray); return _node; } public static JsonNode write(TopicRequest _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeProducersResponseData.java
/* * 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.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 DescribeProducersResponseData implements ApiMessage { int throttleTimeMs; List<TopicResponse> topics; private List<RawTaggedField> _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("topics", new CompactArrayOf(TopicResponse.SCHEMA_0), "Each topic in the response."), 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 DescribeProducersResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeProducersResponseData() { this.throttleTimeMs = 0; this.topics = new ArrayList<TopicResponse>(0); } @Override public short apiKey() { return 61; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<TopicResponse> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicResponse(_readable, _version)); } this.topics = 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.writeInt(throttleTimeMs); _writable.writeUnsignedVarint(topics.size() + 1); for (TopicResponse topicsElement : topics) { topicsElement.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(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); for (TopicResponse topicsElement : topics) { topicsElement.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 DescribeProducersResponseData)) return false; DescribeProducersResponseData other = (DescribeProducersResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public DescribeProducersResponseData duplicate() { DescribeProducersResponseData _duplicate = new DescribeProducersResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; ArrayList<TopicResponse> newTopics = new ArrayList<TopicResponse>(topics.size()); for (TopicResponse _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "DescribeProducersResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public List<TopicResponse> topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeProducersResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeProducersResponseData setTopics(List<TopicResponse> v) { this.topics = v; return this; } public static class TopicResponse implements Message { String name; List<PartitionResponse> partitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.COMPACT_STRING, "The topic name"), new Field("partitions", new CompactArrayOf(PartitionResponse.SCHEMA_0), "Each partition in the response."), 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 TopicResponse(Readable _readable, short _version) { read(_readable, _version); } public TopicResponse() { this.name = ""; this.partitions = new ArrayList<PartitionResponse>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicResponse"); } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } { 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<PartitionResponse> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new PartitionResponse(_readable, _version)); } 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; { byte[] _stringBytes = _cache.getSerializedValue(name); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeUnsignedVarint(partitions.size() + 1); for (PartitionResponse partitionsElement : partitions) { partitionsElement.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 TopicResponse"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1)); for (PartitionResponse partitionsElement : partitions) { partitionsElement.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 TopicResponse)) return false; TopicResponse other = (TopicResponse) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) 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 + (name == null ? 0 : name.hashCode()); hashCode = 31 * hashCode + (partitions == null ? 0 : partitions.hashCode()); return hashCode; } @Override public TopicResponse duplicate() { TopicResponse _duplicate = new TopicResponse(); _duplicate.name = name; ArrayList<PartitionResponse> newPartitions = new ArrayList<PartitionResponse>(partitions.size()); for (PartitionResponse _element : partitions) { newPartitions.add(_element.duplicate()); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicResponse(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String name() { return this.name; } public List<PartitionResponse> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicResponse setName(String v) { this.name = v; return this; } public TopicResponse setPartitions(List<PartitionResponse> v) { this.partitions = v; return this; } } public static class PartitionResponse implements Message { int partitionIndex; short errorCode; String errorMessage; List<ProducerState> activeProducers; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( 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 error."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The partition error message, which may be null if no additional details are available"), new Field("active_producers", new CompactArrayOf(ProducerState.SCHEMA_0), ""), 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 PartitionResponse(Readable _readable, short _version) { read(_readable, _version); } public PartitionResponse() { this.partitionIndex = 0; this.errorCode = (short) 0; this.errorMessage = null; this.activeProducers = new ArrayList<ProducerState>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of PartitionResponse"); } this.partitionIndex = _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 arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field activeProducers 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<ProducerState> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ProducerState(_readable, _version)); } this.activeProducers = 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.writeInt(partitionIndex); _writable.writeShort(errorCode); if (errorMessage == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeUnsignedVarint(activeProducers.size() + 1); for (ProducerState activeProducersElement : activeProducers) { activeProducersElement.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 PartitionResponse"); } _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)); } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(activeProducers.size() + 1)); for (ProducerState activeProducersElement : activeProducers) { activeProducersElement.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 PartitionResponse)) return false; PartitionResponse other = (PartitionResponse) obj; if (partitionIndex != other.partitionIndex) 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.activeProducers == null) { if (other.activeProducers != null) return false; } else { if (!this.activeProducers.equals(other.activeProducers)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode()); hashCode = 31 * hashCode + (activeProducers == null ? 0 : activeProducers.hashCode()); return hashCode; } @Override public PartitionResponse duplicate() { PartitionResponse _duplicate = new PartitionResponse(); _duplicate.partitionIndex = partitionIndex; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } ArrayList<ProducerState> newActiveProducers = new ArrayList<ProducerState>(activeProducers.size()); for (ProducerState _element : activeProducers) { newActiveProducers.add(_element.duplicate()); } _duplicate.activeProducers = newActiveProducers; return _duplicate; } @Override public String toString() { return "PartitionResponse(" + "partitionIndex=" + partitionIndex + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", activeProducers=" + MessageUtil.deepToString(activeProducers.iterator()) + ")"; } public int partitionIndex() { return this.partitionIndex; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public List<ProducerState> activeProducers() { return this.activeProducers; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public PartitionResponse setPartitionIndex(int v) { this.partitionIndex = v; return this; } public PartitionResponse setErrorCode(short v) { this.errorCode = v; return this; } public PartitionResponse setErrorMessage(String v) { this.errorMessage = v; return this; } public PartitionResponse setActiveProducers(List<ProducerState> v) { this.activeProducers = v; return this; } } public static class ProducerState implements Message { long producerId; int producerEpoch; int lastSequence; long lastTimestamp; int coordinatorEpoch; long currentTxnStartOffset; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("producer_id", Type.INT64, ""), new Field("producer_epoch", Type.INT32, ""), new Field("last_sequence", Type.INT32, ""), new Field("last_timestamp", Type.INT64, ""), new Field("coordinator_epoch", Type.INT32, ""), new Field("current_txn_start_offset", Type.INT64, ""), 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 ProducerState(Readable _readable, short _version) { read(_readable, _version); } public ProducerState() { this.producerId = 0L; this.producerEpoch = 0; this.lastSequence = -1; this.lastTimestamp = -1L; this.coordinatorEpoch = 0; this.currentTxnStartOffset = -1L; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of ProducerState"); } this.producerId = _readable.readLong(); this.producerEpoch = _readable.readInt(); this.lastSequence = _readable.readInt(); this.lastTimestamp = _readable.readLong(); this.coordinatorEpoch = _readable.readInt(); this.currentTxnStartOffset = _readable.readLong(); 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.writeLong(producerId); _writable.writeInt(producerEpoch); _writable.writeInt(lastSequence); _writable.writeLong(lastTimestamp); _writable.writeInt(coordinatorEpoch); _writable.writeLong(currentTxnStartOffset); 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 ProducerState"); } _size.addBytes(8); _size.addBytes(4); _size.addBytes(4); _size.addBytes(8); _size.addBytes(4); _size.addBytes(8); 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 ProducerState)) return false; ProducerState other = (ProducerState) obj; if (producerId != other.producerId) return false; if (producerEpoch != other.producerEpoch) return false; if (lastSequence != other.lastSequence) return false; if (lastTimestamp != other.lastTimestamp) return false; if (coordinatorEpoch != other.coordinatorEpoch) return false; if (currentTxnStartOffset != other.currentTxnStartOffset) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + ((int) (producerId >> 32) ^ (int) producerId); hashCode = 31 * hashCode + producerEpoch; hashCode = 31 * hashCode + lastSequence; hashCode = 31 * hashCode + ((int) (lastTimestamp >> 32) ^ (int) lastTimestamp); hashCode = 31 * hashCode + coordinatorEpoch; hashCode = 31 * hashCode + ((int) (currentTxnStartOffset >> 32) ^ (int) currentTxnStartOffset); return hashCode; } @Override public ProducerState duplicate() { ProducerState _duplicate = new ProducerState(); _duplicate.producerId = producerId; _duplicate.producerEpoch = producerEpoch; _duplicate.lastSequence = lastSequence; _duplicate.lastTimestamp = lastTimestamp; _duplicate.coordinatorEpoch = coordinatorEpoch; _duplicate.currentTxnStartOffset = currentTxnStartOffset; return _duplicate; } @Override public String toString() { return "ProducerState(" + "producerId=" + producerId + ", producerEpoch=" + producerEpoch + ", lastSequence=" + lastSequence + ", lastTimestamp=" + lastTimestamp + ", coordinatorEpoch=" + coordinatorEpoch + ", currentTxnStartOffset=" + currentTxnStartOffset + ")"; } public long producerId() { return this.producerId; } public int producerEpoch() { return this.producerEpoch; } public int lastSequence() { return this.lastSequence; } public long lastTimestamp() { return this.lastTimestamp; } public int coordinatorEpoch() { return this.coordinatorEpoch; } public long currentTxnStartOffset() { return this.currentTxnStartOffset; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ProducerState setProducerId(long v) { this.producerId = v; return this; } public ProducerState setProducerEpoch(int v) { this.producerEpoch = v; return this; } public ProducerState setLastSequence(int v) { this.lastSequence = v; return this; } public ProducerState setLastTimestamp(long v) { this.lastTimestamp = v; return this; } public ProducerState setCoordinatorEpoch(int v) { this.coordinatorEpoch = v; return this; } public ProducerState setCurrentTxnStartOffset(long v) { this.currentTxnStartOffset = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeProducersResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeProducersResponseData.*; public class DescribeProducersResponseDataJsonConverter { public static DescribeProducersResponseData read(JsonNode _node, short _version) { DescribeProducersResponseData _object = new DescribeProducersResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeProducersResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeProducersResponseData"); } JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("DescribeProducersResponseData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DescribeProducersResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TopicResponse> _collection = new ArrayList<TopicResponse>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(TopicResponseJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeProducersResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicResponse _element : _object.topics) { _topicsArray.add(TopicResponseJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); return _node; } public static JsonNode write(DescribeProducersResponseData _object, short _version) { return write(_object, _version, true); } public static class PartitionResponseJsonConverter { public static PartitionResponse read(JsonNode _node, short _version) { PartitionResponse _object = new PartitionResponse(); JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("PartitionResponse: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "PartitionResponse"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("PartitionResponse: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "PartitionResponse"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("PartitionResponse: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("PartitionResponse expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _activeProducersNode = _node.get("activeProducers"); if (_activeProducersNode == null) { throw new RuntimeException("PartitionResponse: unable to locate field 'activeProducers', which is mandatory in version " + _version); } else { if (!_activeProducersNode.isArray()) { throw new RuntimeException("PartitionResponse expected a JSON array, but got " + _node.getNodeType()); } ArrayList<ProducerState> _collection = new ArrayList<ProducerState>(_activeProducersNode.size()); _object.activeProducers = _collection; for (JsonNode _element : _activeProducersNode) { _collection.add(ProducerStateJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(PartitionResponse _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } ArrayNode _activeProducersArray = new ArrayNode(JsonNodeFactory.instance); for (ProducerState _element : _object.activeProducers) { _activeProducersArray.add(ProducerStateJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("activeProducers", _activeProducersArray); return _node; } public static JsonNode write(PartitionResponse _object, short _version) { return write(_object, _version, true); } } public static class ProducerStateJsonConverter { public static ProducerState read(JsonNode _node, short _version) { ProducerState _object = new ProducerState(); JsonNode _producerIdNode = _node.get("producerId"); if (_producerIdNode == null) { throw new RuntimeException("ProducerState: unable to locate field 'producerId', which is mandatory in version " + _version); } else { _object.producerId = MessageUtil.jsonNodeToLong(_producerIdNode, "ProducerState"); } JsonNode _producerEpochNode = _node.get("producerEpoch"); if (_producerEpochNode == null) { throw new RuntimeException("ProducerState: unable to locate field 'producerEpoch', which is mandatory in version " + _version); } else { _object.producerEpoch = MessageUtil.jsonNodeToInt(_producerEpochNode, "ProducerState"); } JsonNode _lastSequenceNode = _node.get("lastSequence"); if (_lastSequenceNode == null) { throw new RuntimeException("ProducerState: unable to locate field 'lastSequence', which is mandatory in version " + _version); } else { _object.lastSequence = MessageUtil.jsonNodeToInt(_lastSequenceNode, "ProducerState"); } JsonNode _lastTimestampNode = _node.get("lastTimestamp"); if (_lastTimestampNode == null) { throw new RuntimeException("ProducerState: unable to locate field 'lastTimestamp', which is mandatory in version " + _version); } else { _object.lastTimestamp = MessageUtil.jsonNodeToLong(_lastTimestampNode, "ProducerState"); } JsonNode _coordinatorEpochNode = _node.get("coordinatorEpoch"); if (_coordinatorEpochNode == null) { throw new RuntimeException("ProducerState: unable to locate field 'coordinatorEpoch', which is mandatory in version " + _version); } else { _object.coordinatorEpoch = MessageUtil.jsonNodeToInt(_coordinatorEpochNode, "ProducerState"); } JsonNode _currentTxnStartOffsetNode = _node.get("currentTxnStartOffset"); if (_currentTxnStartOffsetNode == null) { throw new RuntimeException("ProducerState: unable to locate field 'currentTxnStartOffset', which is mandatory in version " + _version); } else { _object.currentTxnStartOffset = MessageUtil.jsonNodeToLong(_currentTxnStartOffsetNode, "ProducerState"); } return _object; } public static JsonNode write(ProducerState _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("producerId", new LongNode(_object.producerId)); _node.set("producerEpoch", new IntNode(_object.producerEpoch)); _node.set("lastSequence", new IntNode(_object.lastSequence)); _node.set("lastTimestamp", new LongNode(_object.lastTimestamp)); _node.set("coordinatorEpoch", new IntNode(_object.coordinatorEpoch)); _node.set("currentTxnStartOffset", new LongNode(_object.currentTxnStartOffset)); return _node; } public static JsonNode write(ProducerState _object, short _version) { return write(_object, _version, true); } } public static class TopicResponseJsonConverter { public static TopicResponse read(JsonNode _node, short _version) { TopicResponse _object = new TopicResponse(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("TopicResponse: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("TopicResponse expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicResponse: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicResponse expected a JSON array, but got " + _node.getNodeType()); } ArrayList<PartitionResponse> _collection = new ArrayList<PartitionResponse>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(PartitionResponseJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(TopicResponse _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (PartitionResponse _element : _object.partitions) { _partitionsArray.add(PartitionResponseJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicResponse _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeQuorumRequestData.java
/* * 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.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 DescribeQuorumRequestData implements ApiMessage { List<TopicData> topics; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topics", new CompactArrayOf(TopicData.SCHEMA_0), ""), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public DescribeQuorumRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeQuorumRequestData() { this.topics = new ArrayList<TopicData>(0); } @Override public short apiKey() { return 55; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<TopicData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicData(_readable, _version)); } this.topics = 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(topics.size() + 1); for (TopicData topicsElement : topics) { topicsElement.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(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); for (TopicData topicsElement : topics) { topicsElement.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 DescribeQuorumRequestData)) return false; DescribeQuorumRequestData other = (DescribeQuorumRequestData) obj; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public DescribeQuorumRequestData duplicate() { DescribeQuorumRequestData _duplicate = new DescribeQuorumRequestData(); ArrayList<TopicData> newTopics = new ArrayList<TopicData>(topics.size()); for (TopicData _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "DescribeQuorumRequestData(" + "topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public List<TopicData> topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeQuorumRequestData setTopics(List<TopicData> v) { this.topics = v; return this; } public static class TopicData implements Message { String topicName; List<PartitionData> partitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topic_name", Type.COMPACT_STRING, "The topic name."), new Field("partitions", new CompactArrayOf(PartitionData.SCHEMA_0), ""), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public TopicData(Readable _readable, short _version) { read(_readable, _version); } public TopicData() { this.topicName = ""; this.partitions = new ArrayList<PartitionData>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { if (_version > 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicData"); } { int length; length = _readable.readUnsignedVarint() - 1; 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); } } { 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<PartitionData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new PartitionData(_readable, _version)); } 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; { byte[] _stringBytes = _cache.getSerializedValue(topicName); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeUnsignedVarint(partitions.size() + 1); for (PartitionData partitionsElement : partitions) { partitionsElement.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 > 1) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicData"); } { 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); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1)); for (PartitionData partitionsElement : partitions) { partitionsElement.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 TopicData)) return false; TopicData other = (TopicData) obj; if (this.topicName == null) { if (other.topicName != null) return false; } else { if (!this.topicName.equals(other.topicName)) 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 + (topicName == null ? 0 : topicName.hashCode()); hashCode = 31 * hashCode + (partitions == null ? 0 : partitions.hashCode()); return hashCode; } @Override public TopicData duplicate() { TopicData _duplicate = new TopicData(); _duplicate.topicName = topicName; ArrayList<PartitionData> newPartitions = new ArrayList<PartitionData>(partitions.size()); for (PartitionData _element : partitions) { newPartitions.add(_element.duplicate()); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicData(" + "topicName=" + ((topicName == null) ? "null" : "'" + topicName.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topicName() { return this.topicName; } public List<PartitionData> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicData setTopicName(String v) { this.topicName = v; return this; } public TopicData setPartitions(List<PartitionData> v) { this.partitions = v; return this; } } public static class PartitionData implements Message { int partitionIndex; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public PartitionData(Readable _readable, short _version) { read(_readable, _version); } public PartitionData() { this.partitionIndex = 0; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { if (_version > 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of PartitionData"); } this.partitionIndex = _readable.readInt(); 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(partitionIndex); 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 > 1) { throw new UnsupportedVersionException("Can't size version " + _version + " of PartitionData"); } _size.addBytes(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 PartitionData)) return false; PartitionData other = (PartitionData) obj; if (partitionIndex != other.partitionIndex) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; return hashCode; } @Override public PartitionData duplicate() { PartitionData _duplicate = new PartitionData(); _duplicate.partitionIndex = partitionIndex; return _duplicate; } @Override public String toString() { return "PartitionData(" + "partitionIndex=" + partitionIndex + ")"; } public int partitionIndex() { return this.partitionIndex; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public PartitionData setPartitionIndex(int v) { this.partitionIndex = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeQuorumRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeQuorumRequestData.*; public class DescribeQuorumRequestDataJsonConverter { public static DescribeQuorumRequestData read(JsonNode _node, short _version) { DescribeQuorumRequestData _object = new DescribeQuorumRequestData(); JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("DescribeQuorumRequestData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DescribeQuorumRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TopicData> _collection = new ArrayList<TopicData>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(TopicDataJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeQuorumRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicData _element : _object.topics) { _topicsArray.add(TopicDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); return _node; } public static JsonNode write(DescribeQuorumRequestData _object, short _version) { return write(_object, _version, true); } public static class PartitionDataJsonConverter { public static PartitionData read(JsonNode _node, short _version) { PartitionData _object = new PartitionData(); JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "PartitionData"); } return _object; } public static JsonNode write(PartitionData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); return _node; } public static JsonNode write(PartitionData _object, short _version) { return write(_object, _version, true); } } public static class TopicDataJsonConverter { public static TopicData read(JsonNode _node, short _version) { TopicData _object = new TopicData(); JsonNode _topicNameNode = _node.get("topicName"); if (_topicNameNode == null) { throw new RuntimeException("TopicData: unable to locate field 'topicName', which is mandatory in version " + _version); } else { if (!_topicNameNode.isTextual()) { throw new RuntimeException("TopicData expected a string type, but got " + _node.getNodeType()); } _object.topicName = _topicNameNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicData: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<PartitionData> _collection = new ArrayList<PartitionData>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(PartitionDataJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(TopicData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topicName", new TextNode(_object.topicName)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (PartitionData _element : _object.partitions) { _partitionsArray.add(PartitionDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicData _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeQuorumResponseData.java
/* * 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.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 DescribeQuorumResponseData implements ApiMessage { short errorCode; List<TopicData> topics; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The top level error code."), new Field("topics", new CompactArrayOf(TopicData.SCHEMA_0), ""), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_1 = new Schema( new Field("error_code", Type.INT16, "The top level error code."), new Field("topics", new CompactArrayOf(TopicData.SCHEMA_1), ""), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public DescribeQuorumResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeQuorumResponseData() { this.errorCode = (short) 0; this.topics = new ArrayList<TopicData>(0); } @Override public short apiKey() { return 55; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { this.errorCode = _readable.readShort(); { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<TopicData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicData(_readable, _version)); } this.topics = 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.writeShort(errorCode); _writable.writeUnsignedVarint(topics.size() + 1); for (TopicData topicsElement : topics) { topicsElement.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(2); { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); for (TopicData topicsElement : topics) { topicsElement.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 DescribeQuorumResponseData)) return false; DescribeQuorumResponseData other = (DescribeQuorumResponseData) obj; if (errorCode != other.errorCode) return false; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public DescribeQuorumResponseData duplicate() { DescribeQuorumResponseData _duplicate = new DescribeQuorumResponseData(); _duplicate.errorCode = errorCode; ArrayList<TopicData> newTopics = new ArrayList<TopicData>(topics.size()); for (TopicData _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "DescribeQuorumResponseData(" + "errorCode=" + errorCode + ", topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public short errorCode() { return this.errorCode; } public List<TopicData> topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeQuorumResponseData setErrorCode(short v) { this.errorCode = v; return this; } public DescribeQuorumResponseData setTopics(List<TopicData> v) { this.topics = v; return this; } public static class TopicData implements Message { String topicName; List<PartitionData> partitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topic_name", Type.COMPACT_STRING, "The topic name."), new Field("partitions", new CompactArrayOf(PartitionData.SCHEMA_0), ""), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_1 = new Schema( new Field("topic_name", Type.COMPACT_STRING, "The topic name."), new Field("partitions", new CompactArrayOf(PartitionData.SCHEMA_1), ""), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public TopicData(Readable _readable, short _version) { read(_readable, _version); } public TopicData() { this.topicName = ""; this.partitions = new ArrayList<PartitionData>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { if (_version > 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicData"); } { int length; length = _readable.readUnsignedVarint() - 1; 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); } } { 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<PartitionData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new PartitionData(_readable, _version)); } 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; { byte[] _stringBytes = _cache.getSerializedValue(topicName); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeUnsignedVarint(partitions.size() + 1); for (PartitionData partitionsElement : partitions) { partitionsElement.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 > 1) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicData"); } { 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); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1)); for (PartitionData partitionsElement : partitions) { partitionsElement.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 TopicData)) return false; TopicData other = (TopicData) obj; if (this.topicName == null) { if (other.topicName != null) return false; } else { if (!this.topicName.equals(other.topicName)) 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 + (topicName == null ? 0 : topicName.hashCode()); hashCode = 31 * hashCode + (partitions == null ? 0 : partitions.hashCode()); return hashCode; } @Override public TopicData duplicate() { TopicData _duplicate = new TopicData(); _duplicate.topicName = topicName; ArrayList<PartitionData> newPartitions = new ArrayList<PartitionData>(partitions.size()); for (PartitionData _element : partitions) { newPartitions.add(_element.duplicate()); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicData(" + "topicName=" + ((topicName == null) ? "null" : "'" + topicName.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topicName() { return this.topicName; } public List<PartitionData> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicData setTopicName(String v) { this.topicName = v; return this; } public TopicData setPartitions(List<PartitionData> v) { this.partitions = v; return this; } } public static class PartitionData implements Message { int partitionIndex; short errorCode; int leaderId; int leaderEpoch; long highWatermark; List<ReplicaState> currentVoters; List<ReplicaState> observers; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("error_code", Type.INT16, ""), new Field("leader_id", Type.INT32, "The ID of the current leader or -1 if the leader is unknown."), new Field("leader_epoch", Type.INT32, "The latest known leader epoch"), new Field("high_watermark", Type.INT64, ""), new Field("current_voters", new CompactArrayOf(ReplicaState.SCHEMA_0), ""), new Field("observers", new CompactArrayOf(ReplicaState.SCHEMA_0), ""), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_1 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("error_code", Type.INT16, ""), new Field("leader_id", Type.INT32, "The ID of the current leader or -1 if the leader is unknown."), new Field("leader_epoch", Type.INT32, "The latest known leader epoch"), new Field("high_watermark", Type.INT64, ""), new Field("current_voters", new CompactArrayOf(ReplicaState.SCHEMA_1), ""), new Field("observers", new CompactArrayOf(ReplicaState.SCHEMA_1), ""), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public PartitionData(Readable _readable, short _version) { read(_readable, _version); } public PartitionData() { this.partitionIndex = 0; this.errorCode = (short) 0; this.leaderId = 0; this.leaderEpoch = 0; this.highWatermark = 0L; this.currentVoters = new ArrayList<ReplicaState>(0); this.observers = new ArrayList<ReplicaState>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 1; } @Override public void read(Readable _readable, short _version) { if (_version > 1) { throw new UnsupportedVersionException("Can't read version " + _version + " of PartitionData"); } this.partitionIndex = _readable.readInt(); this.errorCode = _readable.readShort(); this.leaderId = _readable.readInt(); this.leaderEpoch = _readable.readInt(); this.highWatermark = _readable.readLong(); { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field currentVoters 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<ReplicaState> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ReplicaState(_readable, _version)); } this.currentVoters = newCollection; } } { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field observers 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<ReplicaState> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ReplicaState(_readable, _version)); } this.observers = 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.writeInt(partitionIndex); _writable.writeShort(errorCode); _writable.writeInt(leaderId); _writable.writeInt(leaderEpoch); _writable.writeLong(highWatermark); _writable.writeUnsignedVarint(currentVoters.size() + 1); for (ReplicaState currentVotersElement : currentVoters) { currentVotersElement.write(_writable, _cache, _version); } _writable.writeUnsignedVarint(observers.size() + 1); for (ReplicaState observersElement : observers) { observersElement.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 > 1) { throw new UnsupportedVersionException("Can't size version " + _version + " of PartitionData"); } _size.addBytes(4); _size.addBytes(2); _size.addBytes(4); _size.addBytes(4); _size.addBytes(8); { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(currentVoters.size() + 1)); for (ReplicaState currentVotersElement : currentVoters) { currentVotersElement.addSize(_size, _cache, _version); } } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(observers.size() + 1)); for (ReplicaState observersElement : observers) { observersElement.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 PartitionData)) return false; PartitionData other = (PartitionData) obj; if (partitionIndex != other.partitionIndex) return false; if (errorCode != other.errorCode) return false; if (leaderId != other.leaderId) return false; if (leaderEpoch != other.leaderEpoch) return false; if (highWatermark != other.highWatermark) return false; if (this.currentVoters == null) { if (other.currentVoters != null) return false; } else { if (!this.currentVoters.equals(other.currentVoters)) return false; } if (this.observers == null) { if (other.observers != null) return false; } else { if (!this.observers.equals(other.observers)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + leaderId; hashCode = 31 * hashCode + leaderEpoch; hashCode = 31 * hashCode + ((int) (highWatermark >> 32) ^ (int) highWatermark); hashCode = 31 * hashCode + (currentVoters == null ? 0 : currentVoters.hashCode()); hashCode = 31 * hashCode + (observers == null ? 0 : observers.hashCode()); return hashCode; } @Override public PartitionData duplicate() { PartitionData _duplicate = new PartitionData(); _duplicate.partitionIndex = partitionIndex; _duplicate.errorCode = errorCode; _duplicate.leaderId = leaderId; _duplicate.leaderEpoch = leaderEpoch; _duplicate.highWatermark = highWatermark; ArrayList<ReplicaState> newCurrentVoters = new ArrayList<ReplicaState>(currentVoters.size()); for (ReplicaState _element : currentVoters) { newCurrentVoters.add(_element.duplicate()); } _duplicate.currentVoters = newCurrentVoters; ArrayList<ReplicaState> newObservers = new ArrayList<ReplicaState>(observers.size()); for (ReplicaState _element : observers) { newObservers.add(_element.duplicate()); } _duplicate.observers = newObservers; return _duplicate; } @Override public String toString() { return "PartitionData(" + "partitionIndex=" + partitionIndex + ", errorCode=" + errorCode + ", leaderId=" + leaderId + ", leaderEpoch=" + leaderEpoch + ", highWatermark=" + highWatermark + ", currentVoters=" + MessageUtil.deepToString(currentVoters.iterator()) + ", observers=" + MessageUtil.deepToString(observers.iterator()) + ")"; } public int partitionIndex() { return this.partitionIndex; } public short errorCode() { return this.errorCode; } public int leaderId() { return this.leaderId; } public int leaderEpoch() { return this.leaderEpoch; } public long highWatermark() { return this.highWatermark; } public List<ReplicaState> currentVoters() { return this.currentVoters; } public List<ReplicaState> observers() { return this.observers; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public PartitionData setPartitionIndex(int v) { this.partitionIndex = v; return this; } public PartitionData setErrorCode(short v) { this.errorCode = v; return this; } public PartitionData setLeaderId(int v) { this.leaderId = v; return this; } public PartitionData setLeaderEpoch(int v) { this.leaderEpoch = v; return this; } public PartitionData setHighWatermark(long v) { this.highWatermark = v; return this; } public PartitionData setCurrentVoters(List<ReplicaState> v) { this.currentVoters = v; return this; } public PartitionData setObservers(List<ReplicaState> v) { this.observers = v; return this; } } public static class ReplicaState implements Message { int replicaId; long logEndOffset; long lastFetchTimestamp; long lastCaughtUpTimestamp; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("replica_id", Type.INT32, ""), new Field("log_end_offset", Type.INT64, "The last known log end offset of the follower or -1 if it is unknown"), TaggedFieldsSection.of( ) ); public static final Schema SCHEMA_1 = new Schema( new Field("replica_id", Type.INT32, ""), new Field("log_end_offset", Type.INT64, "The last known log end offset of the follower or -1 if it is unknown"), new Field("last_fetch_timestamp", Type.INT64, "The last known leader wall clock time time when a follower fetched from the leader. This is reported as -1 both for the current leader or if it is unknown for a voter"), new Field("last_caught_up_timestamp", Type.INT64, "The leader wall clock append time of the offset for which the follower made the most recent fetch request. This is reported as the current time for the leader and -1 if unknown for a voter"), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 1; public ReplicaState(Readable _readable, short _version) { read(_readable, _version); } public ReplicaState() { this.replicaId = 0; this.logEndOffset = 0L; this.lastFetchTimestamp = -1L; this.lastCaughtUpTimestamp = -1L; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 32767; } @Override public void read(Readable _readable, short _version) { this.replicaId = _readable.readInt(); this.logEndOffset = _readable.readLong(); if (_version >= 1) { this.lastFetchTimestamp = _readable.readLong(); } else { this.lastFetchTimestamp = -1L; } if (_version >= 1) { this.lastCaughtUpTimestamp = _readable.readLong(); } else { this.lastCaughtUpTimestamp = -1L; } 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(replicaId); _writable.writeLong(logEndOffset); if (_version >= 1) { _writable.writeLong(lastFetchTimestamp); } if (_version >= 1) { _writable.writeLong(lastCaughtUpTimestamp); } 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(8); if (_version >= 1) { _size.addBytes(8); } if (_version >= 1) { _size.addBytes(8); } 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 ReplicaState)) return false; ReplicaState other = (ReplicaState) obj; if (replicaId != other.replicaId) return false; if (logEndOffset != other.logEndOffset) return false; if (lastFetchTimestamp != other.lastFetchTimestamp) return false; if (lastCaughtUpTimestamp != other.lastCaughtUpTimestamp) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + replicaId; hashCode = 31 * hashCode + ((int) (logEndOffset >> 32) ^ (int) logEndOffset); hashCode = 31 * hashCode + ((int) (lastFetchTimestamp >> 32) ^ (int) lastFetchTimestamp); hashCode = 31 * hashCode + ((int) (lastCaughtUpTimestamp >> 32) ^ (int) lastCaughtUpTimestamp); return hashCode; } @Override public ReplicaState duplicate() { ReplicaState _duplicate = new ReplicaState(); _duplicate.replicaId = replicaId; _duplicate.logEndOffset = logEndOffset; _duplicate.lastFetchTimestamp = lastFetchTimestamp; _duplicate.lastCaughtUpTimestamp = lastCaughtUpTimestamp; return _duplicate; } @Override public String toString() { return "ReplicaState(" + "replicaId=" + replicaId + ", logEndOffset=" + logEndOffset + ", lastFetchTimestamp=" + lastFetchTimestamp + ", lastCaughtUpTimestamp=" + lastCaughtUpTimestamp + ")"; } public int replicaId() { return this.replicaId; } public long logEndOffset() { return this.logEndOffset; } public long lastFetchTimestamp() { return this.lastFetchTimestamp; } public long lastCaughtUpTimestamp() { return this.lastCaughtUpTimestamp; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ReplicaState setReplicaId(int v) { this.replicaId = v; return this; } public ReplicaState setLogEndOffset(long v) { this.logEndOffset = v; return this; } public ReplicaState setLastFetchTimestamp(long v) { this.lastFetchTimestamp = v; return this; } public ReplicaState setLastCaughtUpTimestamp(long v) { this.lastCaughtUpTimestamp = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeQuorumResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeQuorumResponseData.*; public class DescribeQuorumResponseDataJsonConverter { public static DescribeQuorumResponseData read(JsonNode _node, short _version) { DescribeQuorumResponseData _object = new DescribeQuorumResponseData(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeQuorumResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeQuorumResponseData"); } JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("DescribeQuorumResponseData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("DescribeQuorumResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TopicData> _collection = new ArrayList<TopicData>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(TopicDataJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeQuorumResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicData _element : _object.topics) { _topicsArray.add(TopicDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); return _node; } public static JsonNode write(DescribeQuorumResponseData _object, short _version) { return write(_object, _version, true); } public static class PartitionDataJsonConverter { public static PartitionData read(JsonNode _node, short _version) { PartitionData _object = new PartitionData(); JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "PartitionData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "PartitionData"); } JsonNode _leaderIdNode = _node.get("leaderId"); if (_leaderIdNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'leaderId', which is mandatory in version " + _version); } else { _object.leaderId = MessageUtil.jsonNodeToInt(_leaderIdNode, "PartitionData"); } JsonNode _leaderEpochNode = _node.get("leaderEpoch"); if (_leaderEpochNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'leaderEpoch', which is mandatory in version " + _version); } else { _object.leaderEpoch = MessageUtil.jsonNodeToInt(_leaderEpochNode, "PartitionData"); } JsonNode _highWatermarkNode = _node.get("highWatermark"); if (_highWatermarkNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'highWatermark', which is mandatory in version " + _version); } else { _object.highWatermark = MessageUtil.jsonNodeToLong(_highWatermarkNode, "PartitionData"); } JsonNode _currentVotersNode = _node.get("currentVoters"); if (_currentVotersNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'currentVoters', which is mandatory in version " + _version); } else { if (!_currentVotersNode.isArray()) { throw new RuntimeException("PartitionData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<ReplicaState> _collection = new ArrayList<ReplicaState>(_currentVotersNode.size()); _object.currentVoters = _collection; for (JsonNode _element : _currentVotersNode) { _collection.add(ReplicaStateJsonConverter.read(_element, _version)); } } JsonNode _observersNode = _node.get("observers"); if (_observersNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'observers', which is mandatory in version " + _version); } else { if (!_observersNode.isArray()) { throw new RuntimeException("PartitionData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<ReplicaState> _collection = new ArrayList<ReplicaState>(_observersNode.size()); _object.observers = _collection; for (JsonNode _element : _observersNode) { _collection.add(ReplicaStateJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(PartitionData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); _node.set("errorCode", new ShortNode(_object.errorCode)); _node.set("leaderId", new IntNode(_object.leaderId)); _node.set("leaderEpoch", new IntNode(_object.leaderEpoch)); _node.set("highWatermark", new LongNode(_object.highWatermark)); ArrayNode _currentVotersArray = new ArrayNode(JsonNodeFactory.instance); for (ReplicaState _element : _object.currentVoters) { _currentVotersArray.add(ReplicaStateJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("currentVoters", _currentVotersArray); ArrayNode _observersArray = new ArrayNode(JsonNodeFactory.instance); for (ReplicaState _element : _object.observers) { _observersArray.add(ReplicaStateJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("observers", _observersArray); return _node; } public static JsonNode write(PartitionData _object, short _version) { return write(_object, _version, true); } } public static class ReplicaStateJsonConverter { public static ReplicaState read(JsonNode _node, short _version) { ReplicaState _object = new ReplicaState(); JsonNode _replicaIdNode = _node.get("replicaId"); if (_replicaIdNode == null) { throw new RuntimeException("ReplicaState: unable to locate field 'replicaId', which is mandatory in version " + _version); } else { _object.replicaId = MessageUtil.jsonNodeToInt(_replicaIdNode, "ReplicaState"); } JsonNode _logEndOffsetNode = _node.get("logEndOffset"); if (_logEndOffsetNode == null) { throw new RuntimeException("ReplicaState: unable to locate field 'logEndOffset', which is mandatory in version " + _version); } else { _object.logEndOffset = MessageUtil.jsonNodeToLong(_logEndOffsetNode, "ReplicaState"); } JsonNode _lastFetchTimestampNode = _node.get("lastFetchTimestamp"); if (_lastFetchTimestampNode == null) { if (_version >= 1) { throw new RuntimeException("ReplicaState: unable to locate field 'lastFetchTimestamp', which is mandatory in version " + _version); } else { _object.lastFetchTimestamp = -1L; } } else { _object.lastFetchTimestamp = MessageUtil.jsonNodeToLong(_lastFetchTimestampNode, "ReplicaState"); } JsonNode _lastCaughtUpTimestampNode = _node.get("lastCaughtUpTimestamp"); if (_lastCaughtUpTimestampNode == null) { if (_version >= 1) { throw new RuntimeException("ReplicaState: unable to locate field 'lastCaughtUpTimestamp', which is mandatory in version " + _version); } else { _object.lastCaughtUpTimestamp = -1L; } } else { _object.lastCaughtUpTimestamp = MessageUtil.jsonNodeToLong(_lastCaughtUpTimestampNode, "ReplicaState"); } return _object; } public static JsonNode write(ReplicaState _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("replicaId", new IntNode(_object.replicaId)); _node.set("logEndOffset", new LongNode(_object.logEndOffset)); if (_version >= 1) { _node.set("lastFetchTimestamp", new LongNode(_object.lastFetchTimestamp)); } if (_version >= 1) { _node.set("lastCaughtUpTimestamp", new LongNode(_object.lastCaughtUpTimestamp)); } return _node; } public static JsonNode write(ReplicaState _object, short _version) { return write(_object, _version, true); } } public static class TopicDataJsonConverter { public static TopicData read(JsonNode _node, short _version) { TopicData _object = new TopicData(); JsonNode _topicNameNode = _node.get("topicName"); if (_topicNameNode == null) { throw new RuntimeException("TopicData: unable to locate field 'topicName', which is mandatory in version " + _version); } else { if (!_topicNameNode.isTextual()) { throw new RuntimeException("TopicData expected a string type, but got " + _node.getNodeType()); } _object.topicName = _topicNameNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicData: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<PartitionData> _collection = new ArrayList<PartitionData>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(PartitionDataJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(TopicData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topicName", new TextNode(_object.topicName)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (PartitionData _element : _object.partitions) { _partitionsArray.add(PartitionDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicData _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeTransactionsRequestData.java
/* * 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.protocol.ApiMessage; 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 DescribeTransactionsRequestData implements ApiMessage { List<String> transactionalIds; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("transactional_ids", new CompactArrayOf(Type.COMPACT_STRING), "Array of transactionalIds to include in describe results. If empty, then no results will be returned."), 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 DescribeTransactionsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeTransactionsRequestData() { this.transactionalIds = new ArrayList<String>(0); } @Override public short apiKey() { return 65; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field transactionalIds 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<String> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field transactionalIds element was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field transactionalIds element had invalid length " + length); } else { newCollection.add(_readable.readString(length)); } } this.transactionalIds = 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(transactionalIds.size() + 1); for (String transactionalIdsElement : transactionalIds) { { byte[] _stringBytes = _cache.getSerializedValue(transactionalIdsElement); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } } 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(ByteUtils.sizeOfUnsignedVarint(transactionalIds.size() + 1)); for (String transactionalIdsElement : transactionalIds) { byte[] _stringBytes = transactionalIdsElement.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'transactionalIdsElement' field is too long to be serialized"); } _cache.cacheSerializedValue(transactionalIdsElement, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } } 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 DescribeTransactionsRequestData)) return false; DescribeTransactionsRequestData other = (DescribeTransactionsRequestData) obj; if (this.transactionalIds == null) { if (other.transactionalIds != null) return false; } else { if (!this.transactionalIds.equals(other.transactionalIds)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (transactionalIds == null ? 0 : transactionalIds.hashCode()); return hashCode; } @Override public DescribeTransactionsRequestData duplicate() { DescribeTransactionsRequestData _duplicate = new DescribeTransactionsRequestData(); ArrayList<String> newTransactionalIds = new ArrayList<String>(transactionalIds.size()); for (String _element : transactionalIds) { newTransactionalIds.add(_element); } _duplicate.transactionalIds = newTransactionalIds; return _duplicate; } @Override public String toString() { return "DescribeTransactionsRequestData(" + "transactionalIds=" + MessageUtil.deepToString(transactionalIds.iterator()) + ")"; } public List<String> transactionalIds() { return this.transactionalIds; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeTransactionsRequestData setTransactionalIds(List<String> v) { this.transactionalIds = v; return this; } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeTransactionsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import static org.apache.kafka.common.message.DescribeTransactionsRequestData.*; public class DescribeTransactionsRequestDataJsonConverter { public static DescribeTransactionsRequestData read(JsonNode _node, short _version) { DescribeTransactionsRequestData _object = new DescribeTransactionsRequestData(); JsonNode _transactionalIdsNode = _node.get("transactionalIds"); if (_transactionalIdsNode == null) { throw new RuntimeException("DescribeTransactionsRequestData: unable to locate field 'transactionalIds', which is mandatory in version " + _version); } else { if (!_transactionalIdsNode.isArray()) { throw new RuntimeException("DescribeTransactionsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<String> _collection = new ArrayList<String>(_transactionalIdsNode.size()); _object.transactionalIds = _collection; for (JsonNode _element : _transactionalIdsNode) { if (!_element.isTextual()) { throw new RuntimeException("DescribeTransactionsRequestData element expected a string type, but got " + _node.getNodeType()); } _collection.add(_element.asText()); } } return _object; } public static JsonNode write(DescribeTransactionsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); ArrayNode _transactionalIdsArray = new ArrayNode(JsonNodeFactory.instance); for (String _element : _object.transactionalIds) { _transactionalIdsArray.add(new TextNode(_element)); } _node.set("transactionalIds", _transactionalIdsArray); return _node; } public static JsonNode write(DescribeTransactionsRequestData _object, short _version) { return write(_object, _version, true); } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeTransactionsResponseData.java
/* * 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.Iterator; 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.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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class DescribeTransactionsResponseData implements ApiMessage { int throttleTimeMs; List<TransactionState> transactionStates; private List<RawTaggedField> _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("transaction_states", new CompactArrayOf(TransactionState.SCHEMA_0), ""), 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 DescribeTransactionsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeTransactionsResponseData() { this.throttleTimeMs = 0; this.transactionStates = new ArrayList<TransactionState>(0); } @Override public short apiKey() { return 65; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field transactionStates 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<TransactionState> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TransactionState(_readable, _version)); } this.transactionStates = 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.writeInt(throttleTimeMs); _writable.writeUnsignedVarint(transactionStates.size() + 1); for (TransactionState transactionStatesElement : transactionStates) { transactionStatesElement.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(ByteUtils.sizeOfUnsignedVarint(transactionStates.size() + 1)); for (TransactionState transactionStatesElement : transactionStates) { transactionStatesElement.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 DescribeTransactionsResponseData)) return false; DescribeTransactionsResponseData other = (DescribeTransactionsResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (this.transactionStates == null) { if (other.transactionStates != null) return false; } else { if (!this.transactionStates.equals(other.transactionStates)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + throttleTimeMs; hashCode = 31 * hashCode + (transactionStates == null ? 0 : transactionStates.hashCode()); return hashCode; } @Override public DescribeTransactionsResponseData duplicate() { DescribeTransactionsResponseData _duplicate = new DescribeTransactionsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; ArrayList<TransactionState> newTransactionStates = new ArrayList<TransactionState>(transactionStates.size()); for (TransactionState _element : transactionStates) { newTransactionStates.add(_element.duplicate()); } _duplicate.transactionStates = newTransactionStates; return _duplicate; } @Override public String toString() { return "DescribeTransactionsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", transactionStates=" + MessageUtil.deepToString(transactionStates.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public List<TransactionState> transactionStates() { return this.transactionStates; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeTransactionsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeTransactionsResponseData setTransactionStates(List<TransactionState> v) { this.transactionStates = v; return this; } public static class TransactionState implements Message { short errorCode; String transactionalId; String transactionState; int transactionTimeoutMs; long transactionStartTimeMs; long producerId; short producerEpoch; TopicDataCollection topics; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, ""), new Field("transactional_id", Type.COMPACT_STRING, ""), new Field("transaction_state", Type.COMPACT_STRING, ""), new Field("transaction_timeout_ms", Type.INT32, ""), new Field("transaction_start_time_ms", Type.INT64, ""), new Field("producer_id", Type.INT64, ""), new Field("producer_epoch", Type.INT16, ""), new Field("topics", new CompactArrayOf(TopicData.SCHEMA_0), "The set of partitions included in the current transaction (if active). When a transaction is preparing to commit or abort, this will include only partitions which do not have markers."), 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 TransactionState(Readable _readable, short _version) { read(_readable, _version); } public TransactionState() { this.errorCode = (short) 0; this.transactionalId = ""; this.transactionState = ""; this.transactionTimeoutMs = 0; this.transactionStartTimeMs = 0L; this.producerId = 0L; this.producerEpoch = (short) 0; this.topics = new TopicDataCollection(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of TransactionState"); } this.errorCode = _readable.readShort(); { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field transactionalId was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field transactionalId had invalid length " + length); } else { this.transactionalId = _readable.readString(length); } } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field transactionState was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field transactionState had invalid length " + length); } else { this.transactionState = _readable.readString(length); } } this.transactionTimeoutMs = _readable.readInt(); this.transactionStartTimeMs = _readable.readLong(); this.producerId = _readable.readLong(); this.producerEpoch = _readable.readShort(); { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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."); } TopicDataCollection newCollection = new TopicDataCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicData(_readable, _version)); } this.topics = 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.writeShort(errorCode); { byte[] _stringBytes = _cache.getSerializedValue(transactionalId); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } { byte[] _stringBytes = _cache.getSerializedValue(transactionState); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeInt(transactionTimeoutMs); _writable.writeLong(transactionStartTimeMs); _writable.writeLong(producerId); _writable.writeShort(producerEpoch); _writable.writeUnsignedVarint(topics.size() + 1); for (TopicData topicsElement : topics) { topicsElement.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 TransactionState"); } _size.addBytes(2); { byte[] _stringBytes = transactionalId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'transactionalId' field is too long to be serialized"); } _cache.cacheSerializedValue(transactionalId, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } { byte[] _stringBytes = transactionState.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'transactionState' field is too long to be serialized"); } _cache.cacheSerializedValue(transactionState, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _size.addBytes(4); _size.addBytes(8); _size.addBytes(8); _size.addBytes(2); { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topics.size() + 1)); for (TopicData topicsElement : topics) { topicsElement.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 TransactionState)) return false; TransactionState other = (TransactionState) obj; if (errorCode != other.errorCode) return false; if (this.transactionalId == null) { if (other.transactionalId != null) return false; } else { if (!this.transactionalId.equals(other.transactionalId)) return false; } if (this.transactionState == null) { if (other.transactionState != null) return false; } else { if (!this.transactionState.equals(other.transactionState)) return false; } if (transactionTimeoutMs != other.transactionTimeoutMs) return false; if (transactionStartTimeMs != other.transactionStartTimeMs) return false; if (producerId != other.producerId) return false; if (producerEpoch != other.producerEpoch) return false; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (transactionalId == null ? 0 : transactionalId.hashCode()); hashCode = 31 * hashCode + (transactionState == null ? 0 : transactionState.hashCode()); hashCode = 31 * hashCode + transactionTimeoutMs; hashCode = 31 * hashCode + ((int) (transactionStartTimeMs >> 32) ^ (int) transactionStartTimeMs); hashCode = 31 * hashCode + ((int) (producerId >> 32) ^ (int) producerId); hashCode = 31 * hashCode + producerEpoch; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public TransactionState duplicate() { TransactionState _duplicate = new TransactionState(); _duplicate.errorCode = errorCode; _duplicate.transactionalId = transactionalId; _duplicate.transactionState = transactionState; _duplicate.transactionTimeoutMs = transactionTimeoutMs; _duplicate.transactionStartTimeMs = transactionStartTimeMs; _duplicate.producerId = producerId; _duplicate.producerEpoch = producerEpoch; TopicDataCollection newTopics = new TopicDataCollection(topics.size()); for (TopicData _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "TransactionState(" + "errorCode=" + errorCode + ", transactionalId=" + ((transactionalId == null) ? "null" : "'" + transactionalId.toString() + "'") + ", transactionState=" + ((transactionState == null) ? "null" : "'" + transactionState.toString() + "'") + ", transactionTimeoutMs=" + transactionTimeoutMs + ", transactionStartTimeMs=" + transactionStartTimeMs + ", producerId=" + producerId + ", producerEpoch=" + producerEpoch + ", topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public short errorCode() { return this.errorCode; } public String transactionalId() { return this.transactionalId; } public String transactionState() { return this.transactionState; } public int transactionTimeoutMs() { return this.transactionTimeoutMs; } public long transactionStartTimeMs() { return this.transactionStartTimeMs; } public long producerId() { return this.producerId; } public short producerEpoch() { return this.producerEpoch; } public TopicDataCollection topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TransactionState setErrorCode(short v) { this.errorCode = v; return this; } public TransactionState setTransactionalId(String v) { this.transactionalId = v; return this; } public TransactionState setTransactionState(String v) { this.transactionState = v; return this; } public TransactionState setTransactionTimeoutMs(int v) { this.transactionTimeoutMs = v; return this; } public TransactionState setTransactionStartTimeMs(long v) { this.transactionStartTimeMs = v; return this; } public TransactionState setProducerId(long v) { this.producerId = v; return this; } public TransactionState setProducerEpoch(short v) { this.producerEpoch = v; return this; } public TransactionState setTopics(TopicDataCollection v) { this.topics = v; return this; } } public static class TopicData implements Message, ImplicitLinkedHashMultiCollection.Element { String topic; List<Integer> partitions; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("topic", Type.COMPACT_STRING, ""), new Field("partitions", new CompactArrayOf(Type.INT32), ""), 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 TopicData(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public TopicData() { this.topic = ""; this.partitions = new ArrayList<Integer>(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicData"); } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field topic was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topic had invalid length " + length); } else { this.topic = _readable.readString(length); } } { 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<Integer> 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; { byte[] _stringBytes = _cache.getSerializedValue(topic); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _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; if (_version > 0) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicData"); } { byte[] _stringBytes = topic.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'topic' field is too long to be serialized"); } _cache.cacheSerializedValue(topic, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } { _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 elementKeysAreEqual(Object obj) { if (!(obj instanceof TopicData)) return false; TopicData other = (TopicData) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof TopicData)) return false; TopicData other = (TopicData) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) 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 + (topic == null ? 0 : topic.hashCode()); return hashCode; } @Override public TopicData duplicate() { TopicData _duplicate = new TopicData(); _duplicate.topic = topic; ArrayList<Integer> newPartitions = new ArrayList<Integer>(partitions.size()); for (Integer _element : partitions) { newPartitions.add(_element); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicData(" + "topic=" + ((topic == null) ? "null" : "'" + topic.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topic() { return this.topic; } public List<Integer> partitions() { return this.partitions; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicData setTopic(String v) { this.topic = v; return this; } public TopicData setPartitions(List<Integer> v) { this.partitions = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class TopicDataCollection extends ImplicitLinkedHashMultiCollection<TopicData> { public TopicDataCollection() { super(); } public TopicDataCollection(int expectedNumElements) { super(expectedNumElements); } public TopicDataCollection(Iterator<TopicData> iterator) { super(iterator); } public TopicData find(String topic) { TopicData _key = new TopicData(); _key.setTopic(topic); return find(_key); } public List<TopicData> findAll(String topic) { TopicData _key = new TopicData(); _key.setTopic(topic); return findAll(_key); } public TopicDataCollection duplicate() { TopicDataCollection _duplicate = new TopicDataCollection(size()); for (TopicData _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeTransactionsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.LongNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeTransactionsResponseData.*; public class DescribeTransactionsResponseDataJsonConverter { public static DescribeTransactionsResponseData read(JsonNode _node, short _version) { DescribeTransactionsResponseData _object = new DescribeTransactionsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeTransactionsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeTransactionsResponseData"); } JsonNode _transactionStatesNode = _node.get("transactionStates"); if (_transactionStatesNode == null) { throw new RuntimeException("DescribeTransactionsResponseData: unable to locate field 'transactionStates', which is mandatory in version " + _version); } else { if (!_transactionStatesNode.isArray()) { throw new RuntimeException("DescribeTransactionsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TransactionState> _collection = new ArrayList<TransactionState>(_transactionStatesNode.size()); _object.transactionStates = _collection; for (JsonNode _element : _transactionStatesNode) { _collection.add(TransactionStateJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeTransactionsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); ArrayNode _transactionStatesArray = new ArrayNode(JsonNodeFactory.instance); for (TransactionState _element : _object.transactionStates) { _transactionStatesArray.add(TransactionStateJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("transactionStates", _transactionStatesArray); return _node; } public static JsonNode write(DescribeTransactionsResponseData _object, short _version) { return write(_object, _version, true); } public static class TopicDataJsonConverter { public static TopicData read(JsonNode _node, short _version) { TopicData _object = new TopicData(); JsonNode _topicNode = _node.get("topic"); if (_topicNode == null) { throw new RuntimeException("TopicData: unable to locate field 'topic', which is mandatory in version " + _version); } else { if (!_topicNode.isTextual()) { throw new RuntimeException("TopicData expected a string type, but got " + _node.getNodeType()); } _object.topic = _topicNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicData: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "TopicData element")); } } return _object; } public static JsonNode write(TopicData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topic", new TextNode(_object.topic)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.partitions) { _partitionsArray.add(new IntNode(_element)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicData _object, short _version) { return write(_object, _version, true); } } public static class TransactionStateJsonConverter { public static TransactionState read(JsonNode _node, short _version) { TransactionState _object = new TransactionState(); JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("TransactionState: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "TransactionState"); } JsonNode _transactionalIdNode = _node.get("transactionalId"); if (_transactionalIdNode == null) { throw new RuntimeException("TransactionState: unable to locate field 'transactionalId', which is mandatory in version " + _version); } else { if (!_transactionalIdNode.isTextual()) { throw new RuntimeException("TransactionState expected a string type, but got " + _node.getNodeType()); } _object.transactionalId = _transactionalIdNode.asText(); } JsonNode _transactionStateNode = _node.get("transactionState"); if (_transactionStateNode == null) { throw new RuntimeException("TransactionState: unable to locate field 'transactionState', which is mandatory in version " + _version); } else { if (!_transactionStateNode.isTextual()) { throw new RuntimeException("TransactionState expected a string type, but got " + _node.getNodeType()); } _object.transactionState = _transactionStateNode.asText(); } JsonNode _transactionTimeoutMsNode = _node.get("transactionTimeoutMs"); if (_transactionTimeoutMsNode == null) { throw new RuntimeException("TransactionState: unable to locate field 'transactionTimeoutMs', which is mandatory in version " + _version); } else { _object.transactionTimeoutMs = MessageUtil.jsonNodeToInt(_transactionTimeoutMsNode, "TransactionState"); } JsonNode _transactionStartTimeMsNode = _node.get("transactionStartTimeMs"); if (_transactionStartTimeMsNode == null) { throw new RuntimeException("TransactionState: unable to locate field 'transactionStartTimeMs', which is mandatory in version " + _version); } else { _object.transactionStartTimeMs = MessageUtil.jsonNodeToLong(_transactionStartTimeMsNode, "TransactionState"); } JsonNode _producerIdNode = _node.get("producerId"); if (_producerIdNode == null) { throw new RuntimeException("TransactionState: unable to locate field 'producerId', which is mandatory in version " + _version); } else { _object.producerId = MessageUtil.jsonNodeToLong(_producerIdNode, "TransactionState"); } JsonNode _producerEpochNode = _node.get("producerEpoch"); if (_producerEpochNode == null) { throw new RuntimeException("TransactionState: unable to locate field 'producerEpoch', which is mandatory in version " + _version); } else { _object.producerEpoch = MessageUtil.jsonNodeToShort(_producerEpochNode, "TransactionState"); } JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("TransactionState: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("TransactionState expected a JSON array, but got " + _node.getNodeType()); } TopicDataCollection _collection = new TopicDataCollection(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(TopicDataJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(TransactionState _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("errorCode", new ShortNode(_object.errorCode)); _node.set("transactionalId", new TextNode(_object.transactionalId)); _node.set("transactionState", new TextNode(_object.transactionState)); _node.set("transactionTimeoutMs", new IntNode(_object.transactionTimeoutMs)); _node.set("transactionStartTimeMs", new LongNode(_object.transactionStartTimeMs)); _node.set("producerId", new LongNode(_object.producerId)); _node.set("producerEpoch", new ShortNode(_object.producerEpoch)); ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicData _element : _object.topics) { _topicsArray.add(TopicDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); return _node; } public static JsonNode write(TransactionState _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeUserScramCredentialsRequestData.java
/* * 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.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 DescribeUserScramCredentialsRequestData implements ApiMessage { List<UserName> users; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("users", CompactArrayOf.nullable(UserName.SCHEMA_0), "The users to describe, or null/empty to describe all users."), 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 DescribeUserScramCredentialsRequestData(Readable _readable, short _version) { read(_readable, _version); } public DescribeUserScramCredentialsRequestData() { this.users = new ArrayList<UserName>(0); } @Override public short apiKey() { return 50; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.users = 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<UserName> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new UserName(_readable, _version)); } this.users = 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; if (users == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(users.size() + 1); for (UserName usersElement : users) { usersElement.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 (users == null) { _size.addBytes(1); } else { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(users.size() + 1)); for (UserName usersElement : users) { usersElement.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 DescribeUserScramCredentialsRequestData)) return false; DescribeUserScramCredentialsRequestData other = (DescribeUserScramCredentialsRequestData) obj; if (this.users == null) { if (other.users != null) return false; } else { if (!this.users.equals(other.users)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (users == null ? 0 : users.hashCode()); return hashCode; } @Override public DescribeUserScramCredentialsRequestData duplicate() { DescribeUserScramCredentialsRequestData _duplicate = new DescribeUserScramCredentialsRequestData(); if (users == null) { _duplicate.users = null; } else { ArrayList<UserName> newUsers = new ArrayList<UserName>(users.size()); for (UserName _element : users) { newUsers.add(_element.duplicate()); } _duplicate.users = newUsers; } return _duplicate; } @Override public String toString() { return "DescribeUserScramCredentialsRequestData(" + "users=" + ((users == null) ? "null" : MessageUtil.deepToString(users.iterator())) + ")"; } public List<UserName> users() { return this.users; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeUserScramCredentialsRequestData setUsers(List<UserName> v) { this.users = v; return this; } public static class UserName implements Message { String name; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("name", Type.COMPACT_STRING, "The user name."), 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 UserName(Readable _readable, short _version) { read(_readable, _version); } public UserName() { this.name = ""; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of UserName"); } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field name was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field name had invalid length " + length); } else { this.name = _readable.readString(length); } } 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; { byte[] _stringBytes = _cache.getSerializedValue(name); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } 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 UserName"); } { byte[] _stringBytes = name.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'name' field is too long to be serialized"); } _cache.cacheSerializedValue(name, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } 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 UserName)) return false; UserName other = (UserName) obj; if (this.name == null) { if (other.name != null) return false; } else { if (!this.name.equals(other.name)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode()); return hashCode; } @Override public UserName duplicate() { UserName _duplicate = new UserName(); _duplicate.name = name; return _duplicate; } @Override public String toString() { return "UserName(" + "name=" + ((name == null) ? "null" : "'" + name.toString() + "'") + ")"; } public String name() { return this.name; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public UserName setName(String v) { this.name = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeUserScramCredentialsRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import static org.apache.kafka.common.message.DescribeUserScramCredentialsRequestData.*; public class DescribeUserScramCredentialsRequestDataJsonConverter { public static DescribeUserScramCredentialsRequestData read(JsonNode _node, short _version) { DescribeUserScramCredentialsRequestData _object = new DescribeUserScramCredentialsRequestData(); JsonNode _usersNode = _node.get("users"); if (_usersNode == null) { throw new RuntimeException("DescribeUserScramCredentialsRequestData: unable to locate field 'users', which is mandatory in version " + _version); } else { if (_usersNode.isNull()) { _object.users = null; } else { if (!_usersNode.isArray()) { throw new RuntimeException("DescribeUserScramCredentialsRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<UserName> _collection = new ArrayList<UserName>(_usersNode.size()); _object.users = _collection; for (JsonNode _element : _usersNode) { _collection.add(UserNameJsonConverter.read(_element, _version)); } } } return _object; } public static JsonNode write(DescribeUserScramCredentialsRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_object.users == null) { _node.set("users", NullNode.instance); } else { ArrayNode _usersArray = new ArrayNode(JsonNodeFactory.instance); for (UserName _element : _object.users) { _usersArray.add(UserNameJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("users", _usersArray); } return _node; } public static JsonNode write(DescribeUserScramCredentialsRequestData _object, short _version) { return write(_object, _version, true); } public static class UserNameJsonConverter { public static UserName read(JsonNode _node, short _version) { UserName _object = new UserName(); JsonNode _nameNode = _node.get("name"); if (_nameNode == null) { throw new RuntimeException("UserName: unable to locate field 'name', which is mandatory in version " + _version); } else { if (!_nameNode.isTextual()) { throw new RuntimeException("UserName expected a string type, but got " + _node.getNodeType()); } _object.name = _nameNode.asText(); } return _object; } public static JsonNode write(UserName _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("name", new TextNode(_object.name)); return _node; } public static JsonNode write(UserName _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeUserScramCredentialsResponseData.java
/* * 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.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 DescribeUserScramCredentialsResponseData implements ApiMessage { int throttleTimeMs; short errorCode; String errorMessage; List<DescribeUserScramCredentialsResult> results; private List<RawTaggedField> _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 message-level error code, 0 except for user authorization or infrastructure issues."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The message-level error message, if any."), new Field("results", new CompactArrayOf(DescribeUserScramCredentialsResult.SCHEMA_0), "The results for descriptions, one per user."), 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 DescribeUserScramCredentialsResponseData(Readable _readable, short _version) { read(_readable, _version); } public DescribeUserScramCredentialsResponseData() { this.throttleTimeMs = 0; this.errorCode = (short) 0; this.errorMessage = ""; this.results = new ArrayList<DescribeUserScramCredentialsResult>(0); } @Override public short apiKey() { return 50; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public 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 arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field results 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<DescribeUserScramCredentialsResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new DescribeUserScramCredentialsResult(_readable, _version)); } this.results = 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.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); } _writable.writeUnsignedVarint(results.size() + 1); for (DescribeUserScramCredentialsResult resultsElement : results) { resultsElement.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)); } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(results.size() + 1)); for (DescribeUserScramCredentialsResult resultsElement : results) { resultsElement.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 DescribeUserScramCredentialsResponseData)) return false; DescribeUserScramCredentialsResponseData other = (DescribeUserScramCredentialsResponseData) 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.results == null) { if (other.results != null) return false; } else { if (!this.results.equals(other.results)) 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 + (results == null ? 0 : results.hashCode()); return hashCode; } @Override public DescribeUserScramCredentialsResponseData duplicate() { DescribeUserScramCredentialsResponseData _duplicate = new DescribeUserScramCredentialsResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } ArrayList<DescribeUserScramCredentialsResult> newResults = new ArrayList<DescribeUserScramCredentialsResult>(results.size()); for (DescribeUserScramCredentialsResult _element : results) { newResults.add(_element.duplicate()); } _duplicate.results = newResults; return _duplicate; } @Override public String toString() { return "DescribeUserScramCredentialsResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", results=" + MessageUtil.deepToString(results.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public List<DescribeUserScramCredentialsResult> results() { return this.results; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeUserScramCredentialsResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public DescribeUserScramCredentialsResponseData setErrorCode(short v) { this.errorCode = v; return this; } public DescribeUserScramCredentialsResponseData setErrorMessage(String v) { this.errorMessage = v; return this; } public DescribeUserScramCredentialsResponseData setResults(List<DescribeUserScramCredentialsResult> v) { this.results = v; return this; } public static class DescribeUserScramCredentialsResult implements Message { String user; short errorCode; String errorMessage; List<CredentialInfo> credentialInfos; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("user", Type.COMPACT_STRING, "The user name."), new Field("error_code", Type.INT16, "The user-level error code."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The user-level error message, if any."), new Field("credential_infos", new CompactArrayOf(CredentialInfo.SCHEMA_0), "The mechanism and related information associated with the user's SCRAM credentials."), 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 DescribeUserScramCredentialsResult(Readable _readable, short _version) { read(_readable, _version); } public DescribeUserScramCredentialsResult() { this.user = ""; this.errorCode = (short) 0; this.errorMessage = ""; this.credentialInfos = new ArrayList<CredentialInfo>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of DescribeUserScramCredentialsResult"); } { int length; length = _readable.readUnsignedVarint() - 1; if (length < 0) { throw new RuntimeException("non-nullable field user was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field user had invalid length " + length); } else { this.user = _readable.readString(length); } } 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 arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field credentialInfos 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<CredentialInfo> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new CredentialInfo(_readable, _version)); } this.credentialInfos = 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; { byte[] _stringBytes = _cache.getSerializedValue(user); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeShort(errorCode); if (errorMessage == null) { _writable.writeUnsignedVarint(0); } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); _writable.writeUnsignedVarint(_stringBytes.length + 1); _writable.writeByteArray(_stringBytes); } _writable.writeUnsignedVarint(credentialInfos.size() + 1); for (CredentialInfo credentialInfosElement : credentialInfos) { credentialInfosElement.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 DescribeUserScramCredentialsResult"); } { byte[] _stringBytes = user.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'user' field is too long to be serialized"); } _cache.cacheSerializedValue(user, _stringBytes); _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } _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)); } { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(credentialInfos.size() + 1)); for (CredentialInfo credentialInfosElement : credentialInfos) { credentialInfosElement.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 DescribeUserScramCredentialsResult)) return false; DescribeUserScramCredentialsResult other = (DescribeUserScramCredentialsResult) obj; if (this.user == null) { if (other.user != null) return false; } else { if (!this.user.equals(other.user)) 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.credentialInfos == null) { if (other.credentialInfos != null) return false; } else { if (!this.credentialInfos.equals(other.credentialInfos)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (user == null ? 0 : user.hashCode()); hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode()); hashCode = 31 * hashCode + (credentialInfos == null ? 0 : credentialInfos.hashCode()); return hashCode; } @Override public DescribeUserScramCredentialsResult duplicate() { DescribeUserScramCredentialsResult _duplicate = new DescribeUserScramCredentialsResult(); _duplicate.user = user; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } ArrayList<CredentialInfo> newCredentialInfos = new ArrayList<CredentialInfo>(credentialInfos.size()); for (CredentialInfo _element : credentialInfos) { newCredentialInfos.add(_element.duplicate()); } _duplicate.credentialInfos = newCredentialInfos; return _duplicate; } @Override public String toString() { return "DescribeUserScramCredentialsResult(" + "user=" + ((user == null) ? "null" : "'" + user.toString() + "'") + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ", credentialInfos=" + MessageUtil.deepToString(credentialInfos.iterator()) + ")"; } public String user() { return this.user; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } public List<CredentialInfo> credentialInfos() { return this.credentialInfos; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public DescribeUserScramCredentialsResult setUser(String v) { this.user = v; return this; } public DescribeUserScramCredentialsResult setErrorCode(short v) { this.errorCode = v; return this; } public DescribeUserScramCredentialsResult setErrorMessage(String v) { this.errorMessage = v; return this; } public DescribeUserScramCredentialsResult setCredentialInfos(List<CredentialInfo> v) { this.credentialInfos = v; return this; } } public static class CredentialInfo implements Message { byte mechanism; int iterations; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("mechanism", Type.INT8, "The SCRAM mechanism."), new Field("iterations", Type.INT32, "The number of iterations used in the SCRAM credential."), 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 CredentialInfo(Readable _readable, short _version) { read(_readable, _version); } public CredentialInfo() { this.mechanism = (byte) 0; this.iterations = 0; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of CredentialInfo"); } this.mechanism = _readable.readByte(); this.iterations = _readable.readInt(); 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.writeByte(mechanism); _writable.writeInt(iterations); 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 CredentialInfo"); } _size.addBytes(1); _size.addBytes(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 CredentialInfo)) return false; CredentialInfo other = (CredentialInfo) obj; if (mechanism != other.mechanism) return false; if (iterations != other.iterations) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + mechanism; hashCode = 31 * hashCode + iterations; return hashCode; } @Override public CredentialInfo duplicate() { CredentialInfo _duplicate = new CredentialInfo(); _duplicate.mechanism = mechanism; _duplicate.iterations = iterations; return _duplicate; } @Override public String toString() { return "CredentialInfo(" + "mechanism=" + mechanism + ", iterations=" + iterations + ")"; } public byte mechanism() { return this.mechanism; } public int iterations() { return this.iterations; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public CredentialInfo setMechanism(byte v) { this.mechanism = v; return this; } public CredentialInfo setIterations(int v) { this.iterations = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/DescribeUserScramCredentialsResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.DescribeUserScramCredentialsResponseData.*; public class DescribeUserScramCredentialsResponseDataJsonConverter { public static DescribeUserScramCredentialsResponseData read(JsonNode _node, short _version) { DescribeUserScramCredentialsResponseData _object = new DescribeUserScramCredentialsResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("DescribeUserScramCredentialsResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "DescribeUserScramCredentialsResponseData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeUserScramCredentialsResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeUserScramCredentialsResponseData"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("DescribeUserScramCredentialsResponseData: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DescribeUserScramCredentialsResponseData expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _resultsNode = _node.get("results"); if (_resultsNode == null) { throw new RuntimeException("DescribeUserScramCredentialsResponseData: unable to locate field 'results', which is mandatory in version " + _version); } else { if (!_resultsNode.isArray()) { throw new RuntimeException("DescribeUserScramCredentialsResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<DescribeUserScramCredentialsResult> _collection = new ArrayList<DescribeUserScramCredentialsResult>(_resultsNode.size()); _object.results = _collection; for (JsonNode _element : _resultsNode) { _collection.add(DescribeUserScramCredentialsResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeUserScramCredentialsResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } ArrayNode _resultsArray = new ArrayNode(JsonNodeFactory.instance); for (DescribeUserScramCredentialsResult _element : _object.results) { _resultsArray.add(DescribeUserScramCredentialsResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("results", _resultsArray); return _node; } public static JsonNode write(DescribeUserScramCredentialsResponseData _object, short _version) { return write(_object, _version, true); } public static class CredentialInfoJsonConverter { public static CredentialInfo read(JsonNode _node, short _version) { CredentialInfo _object = new CredentialInfo(); JsonNode _mechanismNode = _node.get("mechanism"); if (_mechanismNode == null) { throw new RuntimeException("CredentialInfo: unable to locate field 'mechanism', which is mandatory in version " + _version); } else { _object.mechanism = MessageUtil.jsonNodeToByte(_mechanismNode, "CredentialInfo"); } JsonNode _iterationsNode = _node.get("iterations"); if (_iterationsNode == null) { throw new RuntimeException("CredentialInfo: unable to locate field 'iterations', which is mandatory in version " + _version); } else { _object.iterations = MessageUtil.jsonNodeToInt(_iterationsNode, "CredentialInfo"); } return _object; } public static JsonNode write(CredentialInfo _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("mechanism", new ShortNode(_object.mechanism)); _node.set("iterations", new IntNode(_object.iterations)); return _node; } public static JsonNode write(CredentialInfo _object, short _version) { return write(_object, _version, true); } } public static class DescribeUserScramCredentialsResultJsonConverter { public static DescribeUserScramCredentialsResult read(JsonNode _node, short _version) { DescribeUserScramCredentialsResult _object = new DescribeUserScramCredentialsResult(); JsonNode _userNode = _node.get("user"); if (_userNode == null) { throw new RuntimeException("DescribeUserScramCredentialsResult: unable to locate field 'user', which is mandatory in version " + _version); } else { if (!_userNode.isTextual()) { throw new RuntimeException("DescribeUserScramCredentialsResult expected a string type, but got " + _node.getNodeType()); } _object.user = _userNode.asText(); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("DescribeUserScramCredentialsResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "DescribeUserScramCredentialsResult"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("DescribeUserScramCredentialsResult: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("DescribeUserScramCredentialsResult expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } JsonNode _credentialInfosNode = _node.get("credentialInfos"); if (_credentialInfosNode == null) { throw new RuntimeException("DescribeUserScramCredentialsResult: unable to locate field 'credentialInfos', which is mandatory in version " + _version); } else { if (!_credentialInfosNode.isArray()) { throw new RuntimeException("DescribeUserScramCredentialsResult expected a JSON array, but got " + _node.getNodeType()); } ArrayList<CredentialInfo> _collection = new ArrayList<CredentialInfo>(_credentialInfosNode.size()); _object.credentialInfos = _collection; for (JsonNode _element : _credentialInfosNode) { _collection.add(CredentialInfoJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(DescribeUserScramCredentialsResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("user", new TextNode(_object.user)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } ArrayNode _credentialInfosArray = new ArrayNode(JsonNodeFactory.instance); for (CredentialInfo _element : _object.credentialInfos) { _credentialInfosArray.add(CredentialInfoJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("credentialInfos", _credentialInfosArray); return _node; } public static JsonNode write(DescribeUserScramCredentialsResult _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ElectLeadersRequestData.java
/* * 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.Iterator; 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 org.apache.kafka.common.utils.ImplicitLinkedHashCollection; import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection; import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection; public class ElectLeadersRequestData implements ApiMessage { byte electionType; TopicPartitionsCollection topicPartitions; int timeoutMs; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topic_partitions", ArrayOf.nullable(TopicPartitions.SCHEMA_0), "The topic partitions to elect leaders."), new Field("timeout_ms", Type.INT32, "The time in ms to wait for the election to complete.") ); public static final Schema SCHEMA_1 = new Schema( new Field("election_type", Type.INT8, "Type of elections to conduct for the partition. A value of '0' elects the preferred replica. A value of '1' elects the first live replica if there are no in-sync replica."), new Field("topic_partitions", ArrayOf.nullable(TopicPartitions.SCHEMA_0), "The topic partitions to elect leaders."), new Field("timeout_ms", Type.INT32, "The time in ms to wait for the election to complete.") ); public static final Schema SCHEMA_2 = new Schema( new Field("election_type", Type.INT8, "Type of elections to conduct for the partition. A value of '0' elects the preferred replica. A value of '1' elects the first live replica if there are no in-sync replica."), new Field("topic_partitions", CompactArrayOf.nullable(TopicPartitions.SCHEMA_2), "The topic partitions to elect leaders."), new Field("timeout_ms", Type.INT32, "The time in ms to wait for the election to complete."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public ElectLeadersRequestData(Readable _readable, short _version) { read(_readable, _version); } public ElectLeadersRequestData() { this.electionType = (byte) 0; this.topicPartitions = new TopicPartitionsCollection(0); this.timeoutMs = 60000; } @Override public short apiKey() { return 43; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version >= 1) { this.electionType = _readable.readByte(); } else { this.electionType = (byte) 0; } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { this.topicPartitions = 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."); } TopicPartitionsCollection newCollection = new TopicPartitionsCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicPartitions(_readable, _version)); } this.topicPartitions = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { this.topicPartitions = 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."); } TopicPartitionsCollection newCollection = new TopicPartitionsCollection(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicPartitions(_readable, _version)); } this.topicPartitions = newCollection; } } } this.timeoutMs = _readable.readInt(); 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; if (_version >= 1) { _writable.writeByte(electionType); } else { if (this.electionType != (byte) 0) { throw new UnsupportedVersionException("Attempted to write a non-default electionType at version " + _version); } } if (_version >= 2) { if (topicPartitions == null) { _writable.writeUnsignedVarint(0); } else { _writable.writeUnsignedVarint(topicPartitions.size() + 1); for (TopicPartitions topicPartitionsElement : topicPartitions) { topicPartitionsElement.write(_writable, _cache, _version); } } } else { if (topicPartitions == null) { _writable.writeInt(-1); } else { _writable.writeInt(topicPartitions.size()); for (TopicPartitions topicPartitionsElement : topicPartitions) { topicPartitionsElement.write(_writable, _cache, _version); } } } _writable.writeInt(timeoutMs); 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 >= 1) { _size.addBytes(1); } if (topicPartitions == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(4); } } else { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(topicPartitions.size() + 1)); } else { _size.addBytes(4); } for (TopicPartitions topicPartitionsElement : topicPartitions) { topicPartitionsElement.addSize(_size, _cache, _version); } } _size.addBytes(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()); } } 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 ElectLeadersRequestData)) return false; ElectLeadersRequestData other = (ElectLeadersRequestData) obj; if (electionType != other.electionType) return false; if (this.topicPartitions == null) { if (other.topicPartitions != null) return false; } else { if (!this.topicPartitions.equals(other.topicPartitions)) return false; } if (timeoutMs != other.timeoutMs) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + electionType; hashCode = 31 * hashCode + (topicPartitions == null ? 0 : topicPartitions.hashCode()); hashCode = 31 * hashCode + timeoutMs; return hashCode; } @Override public ElectLeadersRequestData duplicate() { ElectLeadersRequestData _duplicate = new ElectLeadersRequestData(); _duplicate.electionType = electionType; if (topicPartitions == null) { _duplicate.topicPartitions = null; } else { TopicPartitionsCollection newTopicPartitions = new TopicPartitionsCollection(topicPartitions.size()); for (TopicPartitions _element : topicPartitions) { newTopicPartitions.add(_element.duplicate()); } _duplicate.topicPartitions = newTopicPartitions; } _duplicate.timeoutMs = timeoutMs; return _duplicate; } @Override public String toString() { return "ElectLeadersRequestData(" + "electionType=" + electionType + ", topicPartitions=" + ((topicPartitions == null) ? "null" : MessageUtil.deepToString(topicPartitions.iterator())) + ", timeoutMs=" + timeoutMs + ")"; } public byte electionType() { return this.electionType; } public TopicPartitionsCollection topicPartitions() { return this.topicPartitions; } public int timeoutMs() { return this.timeoutMs; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ElectLeadersRequestData setElectionType(byte v) { this.electionType = v; return this; } public ElectLeadersRequestData setTopicPartitions(TopicPartitionsCollection v) { this.topicPartitions = v; return this; } public ElectLeadersRequestData setTimeoutMs(int v) { this.timeoutMs = v; return this; } public static class TopicPartitions implements Message, ImplicitLinkedHashMultiCollection.Element { String topic; List<Integer> partitions; private List<RawTaggedField> _unknownTaggedFields; private int next; private int prev; public static final Schema SCHEMA_0 = new Schema( new Field("topic", Type.STRING, "The name of a topic."), new Field("partitions", new ArrayOf(Type.INT32), "The partitions of this topic whose leader should be elected.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("topic", Type.COMPACT_STRING, "The name of a topic."), new Field("partitions", new CompactArrayOf(Type.INT32), "The partitions of this topic whose leader should be elected."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public TopicPartitions(Readable _readable, short _version) { read(_readable, _version); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } public TopicPartitions() { this.topic = ""; this.partitions = new ArrayList<Integer>(0); this.prev = ImplicitLinkedHashCollection.INVALID_INDEX; this.next = ImplicitLinkedHashCollection.INVALID_INDEX; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version > 2) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicPartitions"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field topic was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topic had invalid length " + length); } else { this.topic = _readable.readString(length); } } { int arrayLength; if (_version >= 2) { arrayLength = _readable.readUnsignedVarint() - 1; } else { arrayLength = _readable.readInt(); } 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<Integer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(_readable.readInt()); } this.partitions = 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; { byte[] _stringBytes = _cache.getSerializedValue(topic); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(partitions.size() + 1); } else { _writable.writeInt(partitions.size()); } for (Integer partitionsElement : partitions) { _writable.writeInt(partitionsElement); } 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 > 2) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicPartitions"); } { byte[] _stringBytes = topic.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'topic' field is too long to be serialized"); } _cache.cacheSerializedValue(topic, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1)); } else { _size.addBytes(4); } _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()); } } 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 elementKeysAreEqual(Object obj) { if (!(obj instanceof TopicPartitions)) return false; TopicPartitions other = (TopicPartitions) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) return false; } return true; } @Override public boolean equals(Object obj) { if (!(obj instanceof TopicPartitions)) return false; TopicPartitions other = (TopicPartitions) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) 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 + (topic == null ? 0 : topic.hashCode()); return hashCode; } @Override public TopicPartitions duplicate() { TopicPartitions _duplicate = new TopicPartitions(); _duplicate.topic = topic; ArrayList<Integer> newPartitions = new ArrayList<Integer>(partitions.size()); for (Integer _element : partitions) { newPartitions.add(_element); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicPartitions(" + "topic=" + ((topic == null) ? "null" : "'" + topic.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topic() { return this.topic; } public List<Integer> partitions() { return this.partitions; } @Override public int next() { return this.next; } @Override public int prev() { return this.prev; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicPartitions setTopic(String v) { this.topic = v; return this; } public TopicPartitions setPartitions(List<Integer> v) { this.partitions = v; return this; } @Override public void setNext(int v) { this.next = v; } @Override public void setPrev(int v) { this.prev = v; } } public static class TopicPartitionsCollection extends ImplicitLinkedHashMultiCollection<TopicPartitions> { public TopicPartitionsCollection() { super(); } public TopicPartitionsCollection(int expectedNumElements) { super(expectedNumElements); } public TopicPartitionsCollection(Iterator<TopicPartitions> iterator) { super(iterator); } public TopicPartitions find(String topic) { TopicPartitions _key = new TopicPartitions(); _key.setTopic(topic); return find(_key); } public List<TopicPartitions> findAll(String topic) { TopicPartitions _key = new TopicPartitions(); _key.setTopic(topic); return findAll(_key); } public TopicPartitionsCollection duplicate() { TopicPartitionsCollection _duplicate = new TopicPartitionsCollection(size()); for (TopicPartitions _element : this) { _duplicate.add(_element.duplicate()); } return _duplicate; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ElectLeadersRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.ElectLeadersRequestData.*; public class ElectLeadersRequestDataJsonConverter { public static ElectLeadersRequestData read(JsonNode _node, short _version) { ElectLeadersRequestData _object = new ElectLeadersRequestData(); JsonNode _electionTypeNode = _node.get("electionType"); if (_electionTypeNode == null) { if (_version >= 1) { throw new RuntimeException("ElectLeadersRequestData: unable to locate field 'electionType', which is mandatory in version " + _version); } else { _object.electionType = (byte) 0; } } else { _object.electionType = MessageUtil.jsonNodeToByte(_electionTypeNode, "ElectLeadersRequestData"); } JsonNode _topicPartitionsNode = _node.get("topicPartitions"); if (_topicPartitionsNode == null) { throw new RuntimeException("ElectLeadersRequestData: unable to locate field 'topicPartitions', which is mandatory in version " + _version); } else { if (_topicPartitionsNode.isNull()) { _object.topicPartitions = null; } else { if (!_topicPartitionsNode.isArray()) { throw new RuntimeException("ElectLeadersRequestData expected a JSON array, but got " + _node.getNodeType()); } TopicPartitionsCollection _collection = new TopicPartitionsCollection(_topicPartitionsNode.size()); _object.topicPartitions = _collection; for (JsonNode _element : _topicPartitionsNode) { _collection.add(TopicPartitionsJsonConverter.read(_element, _version)); } } } JsonNode _timeoutMsNode = _node.get("timeoutMs"); if (_timeoutMsNode == null) { throw new RuntimeException("ElectLeadersRequestData: unable to locate field 'timeoutMs', which is mandatory in version " + _version); } else { _object.timeoutMs = MessageUtil.jsonNodeToInt(_timeoutMsNode, "ElectLeadersRequestData"); } return _object; } public static JsonNode write(ElectLeadersRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_version >= 1) { _node.set("electionType", new ShortNode(_object.electionType)); } else { if (_object.electionType != (byte) 0) { throw new UnsupportedVersionException("Attempted to write a non-default electionType at version " + _version); } } if (_object.topicPartitions == null) { _node.set("topicPartitions", NullNode.instance); } else { ArrayNode _topicPartitionsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicPartitions _element : _object.topicPartitions) { _topicPartitionsArray.add(TopicPartitionsJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topicPartitions", _topicPartitionsArray); } _node.set("timeoutMs", new IntNode(_object.timeoutMs)); return _node; } public static JsonNode write(ElectLeadersRequestData _object, short _version) { return write(_object, _version, true); } public static class TopicPartitionsJsonConverter { public static TopicPartitions read(JsonNode _node, short _version) { TopicPartitions _object = new TopicPartitions(); JsonNode _topicNode = _node.get("topic"); if (_topicNode == null) { throw new RuntimeException("TopicPartitions: unable to locate field 'topic', which is mandatory in version " + _version); } else { if (!_topicNode.isTextual()) { throw new RuntimeException("TopicPartitions expected a string type, but got " + _node.getNodeType()); } _object.topic = _topicNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicPartitions: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicPartitions expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "TopicPartitions element")); } } return _object; } public static JsonNode write(TopicPartitions _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topic", new TextNode(_object.topic)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.partitions) { _partitionsArray.add(new IntNode(_element)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicPartitions _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ElectLeadersResponseData.java
/* * 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 ElectLeadersResponseData implements ApiMessage { int throttleTimeMs; short errorCode; List<ReplicaElectionResult> replicaElectionResults; private List<RawTaggedField> _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("replica_election_results", new ArrayOf(ReplicaElectionResult.SCHEMA_0), "The election results, or an empty array if the requester did not have permission and the request asks for all partitions.") ); public static final Schema SCHEMA_1 = 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 response error code."), new Field("replica_election_results", new ArrayOf(ReplicaElectionResult.SCHEMA_0), "The election results, or an empty array if the requester did not have permission and the request asks for all partitions.") ); public static final Schema SCHEMA_2 = 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 response error code."), new Field("replica_election_results", new CompactArrayOf(ReplicaElectionResult.SCHEMA_2), "The election results, or an empty array if the requester did not have permission and the request asks for all partitions."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public ElectLeadersResponseData(Readable _readable, short _version) { read(_readable, _version); } public ElectLeadersResponseData() { this.throttleTimeMs = 0; this.errorCode = (short) 0; this.replicaElectionResults = new ArrayList<ReplicaElectionResult>(0); } @Override public short apiKey() { return 43; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { this.throttleTimeMs = _readable.readInt(); if (_version >= 1) { this.errorCode = _readable.readShort(); } else { this.errorCode = (short) 0; } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field replicaElectionResults 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<ReplicaElectionResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ReplicaElectionResult(_readable, _version)); } this.replicaElectionResults = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field replicaElectionResults 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<ReplicaElectionResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new ReplicaElectionResult(_readable, _version)); } this.replicaElectionResults = 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.writeInt(throttleTimeMs); if (_version >= 1) { _writable.writeShort(errorCode); } else { if (this.errorCode != (short) 0) { throw new UnsupportedVersionException("Attempted to write a non-default errorCode at version " + _version); } } if (_version >= 2) { _writable.writeUnsignedVarint(replicaElectionResults.size() + 1); for (ReplicaElectionResult replicaElectionResultsElement : replicaElectionResults) { replicaElectionResultsElement.write(_writable, _cache, _version); } } else { _writable.writeInt(replicaElectionResults.size()); for (ReplicaElectionResult replicaElectionResultsElement : replicaElectionResults) { replicaElectionResultsElement.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(4); if (_version >= 1) { _size.addBytes(2); } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(replicaElectionResults.size() + 1)); } else { _size.addBytes(4); } for (ReplicaElectionResult replicaElectionResultsElement : replicaElectionResults) { replicaElectionResultsElement.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 ElectLeadersResponseData)) return false; ElectLeadersResponseData other = (ElectLeadersResponseData) obj; if (throttleTimeMs != other.throttleTimeMs) return false; if (errorCode != other.errorCode) return false; if (this.replicaElectionResults == null) { if (other.replicaElectionResults != null) return false; } else { if (!this.replicaElectionResults.equals(other.replicaElectionResults)) 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 + (replicaElectionResults == null ? 0 : replicaElectionResults.hashCode()); return hashCode; } @Override public ElectLeadersResponseData duplicate() { ElectLeadersResponseData _duplicate = new ElectLeadersResponseData(); _duplicate.throttleTimeMs = throttleTimeMs; _duplicate.errorCode = errorCode; ArrayList<ReplicaElectionResult> newReplicaElectionResults = new ArrayList<ReplicaElectionResult>(replicaElectionResults.size()); for (ReplicaElectionResult _element : replicaElectionResults) { newReplicaElectionResults.add(_element.duplicate()); } _duplicate.replicaElectionResults = newReplicaElectionResults; return _duplicate; } @Override public String toString() { return "ElectLeadersResponseData(" + "throttleTimeMs=" + throttleTimeMs + ", errorCode=" + errorCode + ", replicaElectionResults=" + MessageUtil.deepToString(replicaElectionResults.iterator()) + ")"; } public int throttleTimeMs() { return this.throttleTimeMs; } public short errorCode() { return this.errorCode; } public List<ReplicaElectionResult> replicaElectionResults() { return this.replicaElectionResults; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ElectLeadersResponseData setThrottleTimeMs(int v) { this.throttleTimeMs = v; return this; } public ElectLeadersResponseData setErrorCode(short v) { this.errorCode = v; return this; } public ElectLeadersResponseData setReplicaElectionResults(List<ReplicaElectionResult> v) { this.replicaElectionResults = v; return this; } public static class ReplicaElectionResult implements Message { String topic; List<PartitionResult> partitionResult; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topic", Type.STRING, "The topic name"), new Field("partition_result", new ArrayOf(PartitionResult.SCHEMA_0), "The results for each partition") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("topic", Type.COMPACT_STRING, "The topic name"), new Field("partition_result", new CompactArrayOf(PartitionResult.SCHEMA_2), "The results for each partition"), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public ReplicaElectionResult(Readable _readable, short _version) { read(_readable, _version); } public ReplicaElectionResult() { this.topic = ""; this.partitionResult = new ArrayList<PartitionResult>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version > 2) { throw new UnsupportedVersionException("Can't read version " + _version + " of ReplicaElectionResult"); } { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } if (length < 0) { throw new RuntimeException("non-nullable field topic was serialized as null"); } else if (length > 0x7fff) { throw new RuntimeException("string field topic had invalid length " + length); } else { this.topic = _readable.readString(length); } } { if (_version >= 2) { int arrayLength; arrayLength = _readable.readUnsignedVarint() - 1; if (arrayLength < 0) { throw new RuntimeException("non-nullable field partitionResult 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<PartitionResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new PartitionResult(_readable, _version)); } this.partitionResult = newCollection; } } else { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field partitionResult 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<PartitionResult> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new PartitionResult(_readable, _version)); } this.partitionResult = 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; { byte[] _stringBytes = _cache.getSerializedValue(topic); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } if (_version >= 2) { _writable.writeUnsignedVarint(partitionResult.size() + 1); for (PartitionResult partitionResultElement : partitionResult) { partitionResultElement.write(_writable, _cache, _version); } } else { _writable.writeInt(partitionResult.size()); for (PartitionResult partitionResultElement : partitionResult) { partitionResultElement.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; if (_version > 2) { throw new UnsupportedVersionException("Can't size version " + _version + " of ReplicaElectionResult"); } { byte[] _stringBytes = topic.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'topic' field is too long to be serialized"); } _cache.cacheSerializedValue(topic, _stringBytes); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 2); } } { if (_version >= 2) { _size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitionResult.size() + 1)); } else { _size.addBytes(4); } for (PartitionResult partitionResultElement : partitionResult) { partitionResultElement.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 ReplicaElectionResult)) return false; ReplicaElectionResult other = (ReplicaElectionResult) obj; if (this.topic == null) { if (other.topic != null) return false; } else { if (!this.topic.equals(other.topic)) return false; } if (this.partitionResult == null) { if (other.partitionResult != null) return false; } else { if (!this.partitionResult.equals(other.partitionResult)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (topic == null ? 0 : topic.hashCode()); hashCode = 31 * hashCode + (partitionResult == null ? 0 : partitionResult.hashCode()); return hashCode; } @Override public ReplicaElectionResult duplicate() { ReplicaElectionResult _duplicate = new ReplicaElectionResult(); _duplicate.topic = topic; ArrayList<PartitionResult> newPartitionResult = new ArrayList<PartitionResult>(partitionResult.size()); for (PartitionResult _element : partitionResult) { newPartitionResult.add(_element.duplicate()); } _duplicate.partitionResult = newPartitionResult; return _duplicate; } @Override public String toString() { return "ReplicaElectionResult(" + "topic=" + ((topic == null) ? "null" : "'" + topic.toString() + "'") + ", partitionResult=" + MessageUtil.deepToString(partitionResult.iterator()) + ")"; } public String topic() { return this.topic; } public List<PartitionResult> partitionResult() { return this.partitionResult; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public ReplicaElectionResult setTopic(String v) { this.topic = v; return this; } public ReplicaElectionResult setPartitionResult(List<PartitionResult> v) { this.partitionResult = v; return this; } } public static class PartitionResult implements Message { int partitionId; short errorCode; String errorMessage; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("partition_id", Type.INT32, "The partition id"), new Field("error_code", Type.INT16, "The result error, or zero if there was no error."), new Field("error_message", Type.NULLABLE_STRING, "The result message, or null if there was no error.") ); public static final Schema SCHEMA_1 = SCHEMA_0; public static final Schema SCHEMA_2 = new Schema( new Field("partition_id", Type.INT32, "The partition id"), new Field("error_code", Type.INT16, "The result error, or zero if there was no error."), new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The result message, or null if there was no error."), TaggedFieldsSection.of( ) ); public static final Schema[] SCHEMAS = new Schema[] { SCHEMA_0, SCHEMA_1, SCHEMA_2 }; public static final short LOWEST_SUPPORTED_VERSION = 0; public static final short HIGHEST_SUPPORTED_VERSION = 2; public PartitionResult(Readable _readable, short _version) { read(_readable, _version); } public PartitionResult() { this.partitionId = 0; this.errorCode = (short) 0; this.errorMessage = ""; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 2; } @Override public void read(Readable _readable, short _version) { if (_version > 2) { throw new UnsupportedVersionException("Can't read version " + _version + " of PartitionResult"); } this.partitionId = _readable.readInt(); this.errorCode = _readable.readShort(); { int length; if (_version >= 2) { length = _readable.readUnsignedVarint() - 1; } else { length = _readable.readShort(); } 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); } } 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.writeInt(partitionId); _writable.writeShort(errorCode); if (errorMessage == null) { if (_version >= 2) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { byte[] _stringBytes = _cache.getSerializedValue(errorMessage); if (_version >= 2) { _writable.writeUnsignedVarint(_stringBytes.length + 1); } else { _writable.writeShort((short) _stringBytes.length); } _writable.writeByteArray(_stringBytes); } 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 > 2) { throw new UnsupportedVersionException("Can't size version " + _version + " of PartitionResult"); } _size.addBytes(4); _size.addBytes(2); if (errorMessage == null) { if (_version >= 2) { _size.addBytes(1); } else { _size.addBytes(2); } } 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); if (_version >= 2) { _size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1)); } else { _size.addBytes(_stringBytes.length + 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 PartitionResult)) return false; PartitionResult other = (PartitionResult) obj; if (partitionId != other.partitionId) 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; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionId; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode()); return hashCode; } @Override public PartitionResult duplicate() { PartitionResult _duplicate = new PartitionResult(); _duplicate.partitionId = partitionId; _duplicate.errorCode = errorCode; if (errorMessage == null) { _duplicate.errorMessage = null; } else { _duplicate.errorMessage = errorMessage; } return _duplicate; } @Override public String toString() { return "PartitionResult(" + "partitionId=" + partitionId + ", errorCode=" + errorCode + ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'") + ")"; } public int partitionId() { return this.partitionId; } public short errorCode() { return this.errorCode; } public String errorMessage() { return this.errorMessage; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public PartitionResult setPartitionId(int v) { this.partitionId = v; return this; } public PartitionResult setErrorCode(short v) { this.errorCode = v; return this; } public PartitionResult setErrorMessage(String v) { this.errorMessage = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/ElectLeadersResponseDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.errors.UnsupportedVersionException; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.ElectLeadersResponseData.*; public class ElectLeadersResponseDataJsonConverter { public static ElectLeadersResponseData read(JsonNode _node, short _version) { ElectLeadersResponseData _object = new ElectLeadersResponseData(); JsonNode _throttleTimeMsNode = _node.get("throttleTimeMs"); if (_throttleTimeMsNode == null) { throw new RuntimeException("ElectLeadersResponseData: unable to locate field 'throttleTimeMs', which is mandatory in version " + _version); } else { _object.throttleTimeMs = MessageUtil.jsonNodeToInt(_throttleTimeMsNode, "ElectLeadersResponseData"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { if (_version >= 1) { throw new RuntimeException("ElectLeadersResponseData: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = (short) 0; } } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "ElectLeadersResponseData"); } JsonNode _replicaElectionResultsNode = _node.get("replicaElectionResults"); if (_replicaElectionResultsNode == null) { throw new RuntimeException("ElectLeadersResponseData: unable to locate field 'replicaElectionResults', which is mandatory in version " + _version); } else { if (!_replicaElectionResultsNode.isArray()) { throw new RuntimeException("ElectLeadersResponseData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<ReplicaElectionResult> _collection = new ArrayList<ReplicaElectionResult>(_replicaElectionResultsNode.size()); _object.replicaElectionResults = _collection; for (JsonNode _element : _replicaElectionResultsNode) { _collection.add(ReplicaElectionResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(ElectLeadersResponseData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("throttleTimeMs", new IntNode(_object.throttleTimeMs)); if (_version >= 1) { _node.set("errorCode", new ShortNode(_object.errorCode)); } else { if (_object.errorCode != (short) 0) { throw new UnsupportedVersionException("Attempted to write a non-default errorCode at version " + _version); } } ArrayNode _replicaElectionResultsArray = new ArrayNode(JsonNodeFactory.instance); for (ReplicaElectionResult _element : _object.replicaElectionResults) { _replicaElectionResultsArray.add(ReplicaElectionResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("replicaElectionResults", _replicaElectionResultsArray); return _node; } public static JsonNode write(ElectLeadersResponseData _object, short _version) { return write(_object, _version, true); } public static class PartitionResultJsonConverter { public static PartitionResult read(JsonNode _node, short _version) { PartitionResult _object = new PartitionResult(); JsonNode _partitionIdNode = _node.get("partitionId"); if (_partitionIdNode == null) { throw new RuntimeException("PartitionResult: unable to locate field 'partitionId', which is mandatory in version " + _version); } else { _object.partitionId = MessageUtil.jsonNodeToInt(_partitionIdNode, "PartitionResult"); } JsonNode _errorCodeNode = _node.get("errorCode"); if (_errorCodeNode == null) { throw new RuntimeException("PartitionResult: unable to locate field 'errorCode', which is mandatory in version " + _version); } else { _object.errorCode = MessageUtil.jsonNodeToShort(_errorCodeNode, "PartitionResult"); } JsonNode _errorMessageNode = _node.get("errorMessage"); if (_errorMessageNode == null) { throw new RuntimeException("PartitionResult: unable to locate field 'errorMessage', which is mandatory in version " + _version); } else { if (_errorMessageNode.isNull()) { _object.errorMessage = null; } else { if (!_errorMessageNode.isTextual()) { throw new RuntimeException("PartitionResult expected a string type, but got " + _node.getNodeType()); } _object.errorMessage = _errorMessageNode.asText(); } } return _object; } public static JsonNode write(PartitionResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionId", new IntNode(_object.partitionId)); _node.set("errorCode", new ShortNode(_object.errorCode)); if (_object.errorMessage == null) { _node.set("errorMessage", NullNode.instance); } else { _node.set("errorMessage", new TextNode(_object.errorMessage)); } return _node; } public static JsonNode write(PartitionResult _object, short _version) { return write(_object, _version, true); } } public static class ReplicaElectionResultJsonConverter { public static ReplicaElectionResult read(JsonNode _node, short _version) { ReplicaElectionResult _object = new ReplicaElectionResult(); JsonNode _topicNode = _node.get("topic"); if (_topicNode == null) { throw new RuntimeException("ReplicaElectionResult: unable to locate field 'topic', which is mandatory in version " + _version); } else { if (!_topicNode.isTextual()) { throw new RuntimeException("ReplicaElectionResult expected a string type, but got " + _node.getNodeType()); } _object.topic = _topicNode.asText(); } JsonNode _partitionResultNode = _node.get("partitionResult"); if (_partitionResultNode == null) { throw new RuntimeException("ReplicaElectionResult: unable to locate field 'partitionResult', which is mandatory in version " + _version); } else { if (!_partitionResultNode.isArray()) { throw new RuntimeException("ReplicaElectionResult expected a JSON array, but got " + _node.getNodeType()); } ArrayList<PartitionResult> _collection = new ArrayList<PartitionResult>(_partitionResultNode.size()); _object.partitionResult = _collection; for (JsonNode _element : _partitionResultNode) { _collection.add(PartitionResultJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(ReplicaElectionResult _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topic", new TextNode(_object.topic)); ArrayNode _partitionResultArray = new ArrayNode(JsonNodeFactory.instance); for (PartitionResult _element : _object.partitionResult) { _partitionResultArray.add(PartitionResultJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("partitionResult", _partitionResultArray); return _node; } public static JsonNode write(ReplicaElectionResult _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/EndQuorumEpochRequestData.java
/* * 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.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; public class EndQuorumEpochRequestData implements ApiMessage { String clusterId; List<TopicData> topics; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("cluster_id", Type.NULLABLE_STRING, ""), new Field("topics", new ArrayOf(TopicData.SCHEMA_0), "") ); 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 EndQuorumEpochRequestData(Readable _readable, short _version) { read(_readable, _version); } public EndQuorumEpochRequestData() { this.clusterId = null; this.topics = new ArrayList<TopicData>(0); } @Override public short apiKey() { return 54; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { { int length; length = _readable.readShort(); if (length < 0) { this.clusterId = null; } else if (length > 0x7fff) { throw new RuntimeException("string field clusterId had invalid length " + length); } else { this.clusterId = _readable.readString(length); } } { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<TopicData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicData(_readable, _version)); } this.topics = newCollection; } } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; if (clusterId == null) { _writable.writeShort((short) -1); } else { byte[] _stringBytes = _cache.getSerializedValue(clusterId); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } _writable.writeInt(topics.size()); for (TopicData topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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 (clusterId == null) { _size.addBytes(2); } else { byte[] _stringBytes = clusterId.getBytes(StandardCharsets.UTF_8); if (_stringBytes.length > 0x7fff) { throw new RuntimeException("'clusterId' field is too long to be serialized"); } _cache.cacheSerializedValue(clusterId, _stringBytes); _size.addBytes(_stringBytes.length + 2); } { _size.addBytes(4); for (TopicData topicsElement : topics) { topicsElement.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 (_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 EndQuorumEpochRequestData)) return false; EndQuorumEpochRequestData other = (EndQuorumEpochRequestData) obj; if (this.clusterId == null) { if (other.clusterId != null) return false; } else { if (!this.clusterId.equals(other.clusterId)) return false; } if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + (clusterId == null ? 0 : clusterId.hashCode()); hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public EndQuorumEpochRequestData duplicate() { EndQuorumEpochRequestData _duplicate = new EndQuorumEpochRequestData(); if (clusterId == null) { _duplicate.clusterId = null; } else { _duplicate.clusterId = clusterId; } ArrayList<TopicData> newTopics = new ArrayList<TopicData>(topics.size()); for (TopicData _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "EndQuorumEpochRequestData(" + "clusterId=" + ((clusterId == null) ? "null" : "'" + clusterId.toString() + "'") + ", topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public String clusterId() { return this.clusterId; } public List<TopicData> topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public EndQuorumEpochRequestData setClusterId(String v) { this.clusterId = v; return this; } public EndQuorumEpochRequestData setTopics(List<TopicData> v) { this.topics = v; return this; } public static class TopicData implements Message { String topicName; List<PartitionData> partitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topic_name", Type.STRING, "The topic name."), new Field("partitions", new ArrayOf(PartitionData.SCHEMA_0), "") ); 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 TopicData(Readable _readable, short _version) { read(_readable, _version); } public TopicData() { this.topicName = ""; this.partitions = new ArrayList<PartitionData>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicData"); } { int length; 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); } } { int arrayLength; arrayLength = _readable.readInt(); 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<PartitionData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new PartitionData(_readable, _version)); } this.partitions = newCollection; } } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; { byte[] _stringBytes = _cache.getSerializedValue(topicName); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } _writable.writeInt(partitions.size()); for (PartitionData partitionsElement : partitions) { partitionsElement.write(_writable, _cache, _version); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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 > 0) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicData"); } { 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); _size.addBytes(_stringBytes.length + 2); } { _size.addBytes(4); for (PartitionData partitionsElement : partitions) { partitionsElement.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 (_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 TopicData)) return false; TopicData other = (TopicData) obj; if (this.topicName == null) { if (other.topicName != null) return false; } else { if (!this.topicName.equals(other.topicName)) 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 + (topicName == null ? 0 : topicName.hashCode()); hashCode = 31 * hashCode + (partitions == null ? 0 : partitions.hashCode()); return hashCode; } @Override public TopicData duplicate() { TopicData _duplicate = new TopicData(); _duplicate.topicName = topicName; ArrayList<PartitionData> newPartitions = new ArrayList<PartitionData>(partitions.size()); for (PartitionData _element : partitions) { newPartitions.add(_element.duplicate()); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicData(" + "topicName=" + ((topicName == null) ? "null" : "'" + topicName.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topicName() { return this.topicName; } public List<PartitionData> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicData setTopicName(String v) { this.topicName = v; return this; } public TopicData setPartitions(List<PartitionData> v) { this.partitions = v; return this; } } public static class PartitionData implements Message { int partitionIndex; int leaderId; int leaderEpoch; List<Integer> preferredSuccessors; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("leader_id", Type.INT32, "The current leader ID that is resigning"), new Field("leader_epoch", Type.INT32, "The current epoch"), new Field("preferred_successors", new ArrayOf(Type.INT32), "A sorted list of preferred successors to start the election") ); 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 PartitionData(Readable _readable, short _version) { read(_readable, _version); } public PartitionData() { this.partitionIndex = 0; this.leaderId = 0; this.leaderEpoch = 0; this.preferredSuccessors = new ArrayList<Integer>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of PartitionData"); } this.partitionIndex = _readable.readInt(); this.leaderId = _readable.readInt(); this.leaderEpoch = _readable.readInt(); { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field preferredSuccessors 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<Integer> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(_readable.readInt()); } this.preferredSuccessors = newCollection; } } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; _writable.writeInt(partitionIndex); _writable.writeInt(leaderId); _writable.writeInt(leaderEpoch); _writable.writeInt(preferredSuccessors.size()); for (Integer preferredSuccessorsElement : preferredSuccessors) { _writable.writeInt(preferredSuccessorsElement); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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 > 0) { throw new UnsupportedVersionException("Can't size version " + _version + " of PartitionData"); } _size.addBytes(4); _size.addBytes(4); _size.addBytes(4); { _size.addBytes(4); _size.addBytes(preferredSuccessors.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()); } } 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 PartitionData)) return false; PartitionData other = (PartitionData) obj; if (partitionIndex != other.partitionIndex) return false; if (leaderId != other.leaderId) return false; if (leaderEpoch != other.leaderEpoch) return false; if (this.preferredSuccessors == null) { if (other.preferredSuccessors != null) return false; } else { if (!this.preferredSuccessors.equals(other.preferredSuccessors)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; hashCode = 31 * hashCode + leaderId; hashCode = 31 * hashCode + leaderEpoch; hashCode = 31 * hashCode + (preferredSuccessors == null ? 0 : preferredSuccessors.hashCode()); return hashCode; } @Override public PartitionData duplicate() { PartitionData _duplicate = new PartitionData(); _duplicate.partitionIndex = partitionIndex; _duplicate.leaderId = leaderId; _duplicate.leaderEpoch = leaderEpoch; ArrayList<Integer> newPreferredSuccessors = new ArrayList<Integer>(preferredSuccessors.size()); for (Integer _element : preferredSuccessors) { newPreferredSuccessors.add(_element); } _duplicate.preferredSuccessors = newPreferredSuccessors; return _duplicate; } @Override public String toString() { return "PartitionData(" + "partitionIndex=" + partitionIndex + ", leaderId=" + leaderId + ", leaderEpoch=" + leaderEpoch + ", preferredSuccessors=" + MessageUtil.deepToString(preferredSuccessors.iterator()) + ")"; } public int partitionIndex() { return this.partitionIndex; } public int leaderId() { return this.leaderId; } public int leaderEpoch() { return this.leaderEpoch; } public List<Integer> preferredSuccessors() { return this.preferredSuccessors; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public PartitionData setPartitionIndex(int v) { this.partitionIndex = v; return this; } public PartitionData setLeaderId(int v) { this.leaderId = v; return this; } public PartitionData setLeaderEpoch(int v) { this.leaderEpoch = v; return this; } public PartitionData setPreferredSuccessors(List<Integer> v) { this.preferredSuccessors = v; return this; } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/EndQuorumEpochRequestDataJsonConverter.java
/* * 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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import java.util.ArrayList; import org.apache.kafka.common.protocol.MessageUtil; import static org.apache.kafka.common.message.EndQuorumEpochRequestData.*; public class EndQuorumEpochRequestDataJsonConverter { public static EndQuorumEpochRequestData read(JsonNode _node, short _version) { EndQuorumEpochRequestData _object = new EndQuorumEpochRequestData(); JsonNode _clusterIdNode = _node.get("clusterId"); if (_clusterIdNode == null) { throw new RuntimeException("EndQuorumEpochRequestData: unable to locate field 'clusterId', which is mandatory in version " + _version); } else { if (_clusterIdNode.isNull()) { _object.clusterId = null; } else { if (!_clusterIdNode.isTextual()) { throw new RuntimeException("EndQuorumEpochRequestData expected a string type, but got " + _node.getNodeType()); } _object.clusterId = _clusterIdNode.asText(); } } JsonNode _topicsNode = _node.get("topics"); if (_topicsNode == null) { throw new RuntimeException("EndQuorumEpochRequestData: unable to locate field 'topics', which is mandatory in version " + _version); } else { if (!_topicsNode.isArray()) { throw new RuntimeException("EndQuorumEpochRequestData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<TopicData> _collection = new ArrayList<TopicData>(_topicsNode.size()); _object.topics = _collection; for (JsonNode _element : _topicsNode) { _collection.add(TopicDataJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(EndQuorumEpochRequestData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); if (_object.clusterId == null) { _node.set("clusterId", NullNode.instance); } else { _node.set("clusterId", new TextNode(_object.clusterId)); } ArrayNode _topicsArray = new ArrayNode(JsonNodeFactory.instance); for (TopicData _element : _object.topics) { _topicsArray.add(TopicDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("topics", _topicsArray); return _node; } public static JsonNode write(EndQuorumEpochRequestData _object, short _version) { return write(_object, _version, true); } public static class PartitionDataJsonConverter { public static PartitionData read(JsonNode _node, short _version) { PartitionData _object = new PartitionData(); JsonNode _partitionIndexNode = _node.get("partitionIndex"); if (_partitionIndexNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'partitionIndex', which is mandatory in version " + _version); } else { _object.partitionIndex = MessageUtil.jsonNodeToInt(_partitionIndexNode, "PartitionData"); } JsonNode _leaderIdNode = _node.get("leaderId"); if (_leaderIdNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'leaderId', which is mandatory in version " + _version); } else { _object.leaderId = MessageUtil.jsonNodeToInt(_leaderIdNode, "PartitionData"); } JsonNode _leaderEpochNode = _node.get("leaderEpoch"); if (_leaderEpochNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'leaderEpoch', which is mandatory in version " + _version); } else { _object.leaderEpoch = MessageUtil.jsonNodeToInt(_leaderEpochNode, "PartitionData"); } JsonNode _preferredSuccessorsNode = _node.get("preferredSuccessors"); if (_preferredSuccessorsNode == null) { throw new RuntimeException("PartitionData: unable to locate field 'preferredSuccessors', which is mandatory in version " + _version); } else { if (!_preferredSuccessorsNode.isArray()) { throw new RuntimeException("PartitionData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<Integer> _collection = new ArrayList<Integer>(_preferredSuccessorsNode.size()); _object.preferredSuccessors = _collection; for (JsonNode _element : _preferredSuccessorsNode) { _collection.add(MessageUtil.jsonNodeToInt(_element, "PartitionData element")); } } return _object; } public static JsonNode write(PartitionData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("partitionIndex", new IntNode(_object.partitionIndex)); _node.set("leaderId", new IntNode(_object.leaderId)); _node.set("leaderEpoch", new IntNode(_object.leaderEpoch)); ArrayNode _preferredSuccessorsArray = new ArrayNode(JsonNodeFactory.instance); for (Integer _element : _object.preferredSuccessors) { _preferredSuccessorsArray.add(new IntNode(_element)); } _node.set("preferredSuccessors", _preferredSuccessorsArray); return _node; } public static JsonNode write(PartitionData _object, short _version) { return write(_object, _version, true); } } public static class TopicDataJsonConverter { public static TopicData read(JsonNode _node, short _version) { TopicData _object = new TopicData(); JsonNode _topicNameNode = _node.get("topicName"); if (_topicNameNode == null) { throw new RuntimeException("TopicData: unable to locate field 'topicName', which is mandatory in version " + _version); } else { if (!_topicNameNode.isTextual()) { throw new RuntimeException("TopicData expected a string type, but got " + _node.getNodeType()); } _object.topicName = _topicNameNode.asText(); } JsonNode _partitionsNode = _node.get("partitions"); if (_partitionsNode == null) { throw new RuntimeException("TopicData: unable to locate field 'partitions', which is mandatory in version " + _version); } else { if (!_partitionsNode.isArray()) { throw new RuntimeException("TopicData expected a JSON array, but got " + _node.getNodeType()); } ArrayList<PartitionData> _collection = new ArrayList<PartitionData>(_partitionsNode.size()); _object.partitions = _collection; for (JsonNode _element : _partitionsNode) { _collection.add(PartitionDataJsonConverter.read(_element, _version)); } } return _object; } public static JsonNode write(TopicData _object, short _version, boolean _serializeRecords) { ObjectNode _node = new ObjectNode(JsonNodeFactory.instance); _node.set("topicName", new TextNode(_object.topicName)); ArrayNode _partitionsArray = new ArrayNode(JsonNodeFactory.instance); for (PartitionData _element : _object.partitions) { _partitionsArray.add(PartitionDataJsonConverter.write(_element, _version, _serializeRecords)); } _node.set("partitions", _partitionsArray); return _node; } public static JsonNode write(TopicData _object, short _version) { return write(_object, _version, true); } } }
0
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common
java-sources/ai/superstream/kafka-clients/3.5.118/org/apache/kafka/common/message/EndQuorumEpochResponseData.java
/* * 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.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; public class EndQuorumEpochResponseData implements ApiMessage { short errorCode; List<TopicData> topics; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("error_code", Type.INT16, "The top level error code."), new Field("topics", new ArrayOf(TopicData.SCHEMA_0), "") ); 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 EndQuorumEpochResponseData(Readable _readable, short _version) { read(_readable, _version); } public EndQuorumEpochResponseData() { this.errorCode = (short) 0; this.topics = new ArrayList<TopicData>(0); } @Override public short apiKey() { return 54; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { this.errorCode = _readable.readShort(); { int arrayLength; arrayLength = _readable.readInt(); if (arrayLength < 0) { throw new RuntimeException("non-nullable field topics 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<TopicData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new TopicData(_readable, _version)); } this.topics = newCollection; } } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; _writable.writeShort(errorCode); _writable.writeInt(topics.size()); for (TopicData topicsElement : topics) { topicsElement.write(_writable, _cache, _version); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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); { _size.addBytes(4); for (TopicData topicsElement : topics) { topicsElement.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 (_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 EndQuorumEpochResponseData)) return false; EndQuorumEpochResponseData other = (EndQuorumEpochResponseData) obj; if (errorCode != other.errorCode) return false; if (this.topics == null) { if (other.topics != null) return false; } else { if (!this.topics.equals(other.topics)) return false; } return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode()); return hashCode; } @Override public EndQuorumEpochResponseData duplicate() { EndQuorumEpochResponseData _duplicate = new EndQuorumEpochResponseData(); _duplicate.errorCode = errorCode; ArrayList<TopicData> newTopics = new ArrayList<TopicData>(topics.size()); for (TopicData _element : topics) { newTopics.add(_element.duplicate()); } _duplicate.topics = newTopics; return _duplicate; } @Override public String toString() { return "EndQuorumEpochResponseData(" + "errorCode=" + errorCode + ", topics=" + MessageUtil.deepToString(topics.iterator()) + ")"; } public short errorCode() { return this.errorCode; } public List<TopicData> topics() { return this.topics; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public EndQuorumEpochResponseData setErrorCode(short v) { this.errorCode = v; return this; } public EndQuorumEpochResponseData setTopics(List<TopicData> v) { this.topics = v; return this; } public static class TopicData implements Message { String topicName; List<PartitionData> partitions; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("topic_name", Type.STRING, "The topic name."), new Field("partitions", new ArrayOf(PartitionData.SCHEMA_0), "") ); 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 TopicData(Readable _readable, short _version) { read(_readable, _version); } public TopicData() { this.topicName = ""; this.partitions = new ArrayList<PartitionData>(0); } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of TopicData"); } { int length; 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); } } { int arrayLength; arrayLength = _readable.readInt(); 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<PartitionData> newCollection = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; i++) { newCollection.add(new PartitionData(_readable, _version)); } this.partitions = newCollection; } } this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; { byte[] _stringBytes = _cache.getSerializedValue(topicName); _writable.writeShort((short) _stringBytes.length); _writable.writeByteArray(_stringBytes); } _writable.writeInt(partitions.size()); for (PartitionData partitionsElement : partitions) { partitionsElement.write(_writable, _cache, _version); } RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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 > 0) { throw new UnsupportedVersionException("Can't size version " + _version + " of TopicData"); } { 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); _size.addBytes(_stringBytes.length + 2); } { _size.addBytes(4); for (PartitionData partitionsElement : partitions) { partitionsElement.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 (_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 TopicData)) return false; TopicData other = (TopicData) obj; if (this.topicName == null) { if (other.topicName != null) return false; } else { if (!this.topicName.equals(other.topicName)) 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 + (topicName == null ? 0 : topicName.hashCode()); hashCode = 31 * hashCode + (partitions == null ? 0 : partitions.hashCode()); return hashCode; } @Override public TopicData duplicate() { TopicData _duplicate = new TopicData(); _duplicate.topicName = topicName; ArrayList<PartitionData> newPartitions = new ArrayList<PartitionData>(partitions.size()); for (PartitionData _element : partitions) { newPartitions.add(_element.duplicate()); } _duplicate.partitions = newPartitions; return _duplicate; } @Override public String toString() { return "TopicData(" + "topicName=" + ((topicName == null) ? "null" : "'" + topicName.toString() + "'") + ", partitions=" + MessageUtil.deepToString(partitions.iterator()) + ")"; } public String topicName() { return this.topicName; } public List<PartitionData> partitions() { return this.partitions; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public TopicData setTopicName(String v) { this.topicName = v; return this; } public TopicData setPartitions(List<PartitionData> v) { this.partitions = v; return this; } } public static class PartitionData implements Message { int partitionIndex; short errorCode; int leaderId; int leaderEpoch; private List<RawTaggedField> _unknownTaggedFields; public static final Schema SCHEMA_0 = new Schema( new Field("partition_index", Type.INT32, "The partition index."), new Field("error_code", Type.INT16, ""), new Field("leader_id", Type.INT32, "The ID of the current leader or -1 if the leader is unknown."), new Field("leader_epoch", Type.INT32, "The latest known leader epoch") ); 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 PartitionData(Readable _readable, short _version) { read(_readable, _version); } public PartitionData() { this.partitionIndex = 0; this.errorCode = (short) 0; this.leaderId = 0; this.leaderEpoch = 0; } @Override public short lowestSupportedVersion() { return 0; } @Override public short highestSupportedVersion() { return 0; } @Override public void read(Readable _readable, short _version) { if (_version > 0) { throw new UnsupportedVersionException("Can't read version " + _version + " of PartitionData"); } this.partitionIndex = _readable.readInt(); this.errorCode = _readable.readShort(); this.leaderId = _readable.readInt(); this.leaderEpoch = _readable.readInt(); this._unknownTaggedFields = null; } @Override public void write(Writable _writable, ObjectSerializationCache _cache, short _version) { int _numTaggedFields = 0; _writable.writeInt(partitionIndex); _writable.writeShort(errorCode); _writable.writeInt(leaderId); _writable.writeInt(leaderEpoch); RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields); _numTaggedFields += _rawWriter.numFields(); 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 > 0) { throw new UnsupportedVersionException("Can't size version " + _version + " of PartitionData"); } _size.addBytes(4); _size.addBytes(2); _size.addBytes(4); _size.addBytes(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()); } } 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 PartitionData)) return false; PartitionData other = (PartitionData) obj; if (partitionIndex != other.partitionIndex) return false; if (errorCode != other.errorCode) return false; if (leaderId != other.leaderId) return false; if (leaderEpoch != other.leaderEpoch) return false; return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields); } @Override public int hashCode() { int hashCode = 0; hashCode = 31 * hashCode + partitionIndex; hashCode = 31 * hashCode + errorCode; hashCode = 31 * hashCode + leaderId; hashCode = 31 * hashCode + leaderEpoch; return hashCode; } @Override public PartitionData duplicate() { PartitionData _duplicate = new PartitionData(); _duplicate.partitionIndex = partitionIndex; _duplicate.errorCode = errorCode; _duplicate.leaderId = leaderId; _duplicate.leaderEpoch = leaderEpoch; return _duplicate; } @Override public String toString() { return "PartitionData(" + "partitionIndex=" + partitionIndex + ", errorCode=" + errorCode + ", leaderId=" + leaderId + ", leaderEpoch=" + leaderEpoch + ")"; } public int partitionIndex() { return this.partitionIndex; } public short errorCode() { return this.errorCode; } public int leaderId() { return this.leaderId; } public int leaderEpoch() { return this.leaderEpoch; } @Override public List<RawTaggedField> unknownTaggedFields() { if (_unknownTaggedFields == null) { _unknownTaggedFields = new ArrayList<>(0); } return _unknownTaggedFields; } public PartitionData setPartitionIndex(int v) { this.partitionIndex = v; return this; } public PartitionData setErrorCode(short v) { this.errorCode = v; return this; } public PartitionData setLeaderId(int v) { this.leaderId = v; return this; } public PartitionData setLeaderEpoch(int v) { this.leaderEpoch = v; return this; } } }