adixitconfluent commented on code in PR #23360: URL: https://github.com/apache/kafka/pull/23360#discussion_r3960823205
########## server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordHelper.java: ########## @@ -0,0 +1,265 @@ +/* + * 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. + */ + +package org.apache.kafka.server.share.dlq; + +import org.apache.kafka.common.TopicIdPartition; +import org.apache.kafka.common.Uuid; +import org.apache.kafka.common.compress.Compression; +import org.apache.kafka.common.header.Header; +import org.apache.kafka.common.header.internals.RecordHeader; +import org.apache.kafka.common.record.internal.DefaultRecord; +import org.apache.kafka.common.record.internal.DefaultRecordBatch; +import org.apache.kafka.common.record.internal.MemoryRecords; +import org.apache.kafka.common.record.internal.Record; +import org.apache.kafka.common.record.internal.SimpleRecord; +import org.apache.kafka.common.utils.Time; +import org.apache.kafka.server.share.LogReader; + +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; + +/** + * Helper for DLQ record building and source-record fetching. + */ +public class ShareGroupDLQRecordHelper { + + /** + * In most cases we expect the records getting DLQ'ed will be single offsets and + * not complete batches. Hence, using a large upper limit while reading from the log + * would be fruitless in most cases. Therefore, the value of 1 MB has been chosen + * for the DLQ-related log reads. + */ + private static final int DLQ_MAX_FETCH_BYTES = 1024 * 1024; + + public static final String HEADER_DLQ_ERRORS_TOPIC = "__dlq.errors.topic"; + public static final String HEADER_DLQ_ERRORS_PARTITION = "__dlq.errors.partition"; + public static final String HEADER_DLQ_ERRORS_OFFSET = "__dlq.errors.offset"; + public static final String HEADER_DLQ_ERRORS_GROUP = "__dlq.errors.group"; + public static final String HEADER_DLQ_ERRORS_DELIVERY_COUNT = "__dlq.errors.delivery.count"; + public static final String HEADER_DLQ_ERRORS_MESSAGE = "__dlq.errors.message"; Review Comment: made it protected ########## clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ShareConsumerDLQTest.java: ########## @@ -583,6 +583,10 @@ public void testDlqRespectsDlqTopicMaxMessageBytesNotEqToSourceTopic() throws Ex }, DEFAULT_MAX_WAIT_MS, 100L, () -> "Raised max.message.bytes did not propagate on the DLQ topic"); } + // Hook for any future subclasses whose DLQ manager caches topic config (e.g. max.message.bytes) Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
