johnny94 commented on code in PR #19793:
URL: https://github.com/apache/kafka/pull/19793#discussion_r2726734618


##########
server/src/main/java/org/apache/kafka/server/purgatory/DelayedProduce.java:
##########
@@ -0,0 +1,214 @@
+/*
+ * 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.purgatory;
+
+import org.apache.kafka.common.TopicIdPartition;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.common.requests.ProduceResponse.PartitionResponse;
+import org.apache.kafka.server.metrics.KafkaMetricsGroup;
+
+import com.yammer.metrics.core.Meter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiFunction;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * A delayed produce operation that can be created by the replica manager and 
watched
+ * in the produce operation purgatory
+ */
+public class DelayedProduce extends DelayedOperation {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(DelayedProduce.class);
+
+    public static final class ProducePartitionStatus {
+        private final long requiredOffset;
+        private final PartitionResponse responseStatus;
+
+        private volatile boolean acksPending;
+
+        public ProducePartitionStatus(long requiredOffset, PartitionResponse 
responseStatus) {
+            this.requiredOffset = requiredOffset;
+            this.responseStatus = responseStatus;
+        }
+
+        public long requiredOffset() {
+            return requiredOffset;
+        }
+
+        public PartitionResponse responseStatus() {
+            return responseStatus;
+        }
+
+        public boolean acksPending() {
+            return acksPending;
+        }
+
+        public void setAcksPending(boolean acksPending) {
+            this.acksPending = acksPending;
+        }
+
+        @Override
+        public String toString() {
+            return String.format(
+                    "[acksPending: %s, error: %s, startOffset: %s, 
requiredOffset: %d]",
+                    acksPending,
+                    responseStatus.error.code(),
+                    responseStatus.baseOffset,
+                    requiredOffset
+            );
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
+            final ProducePartitionStatus that = (ProducePartitionStatus) o;
+            return requiredOffset == that.requiredOffset && acksPending == 
that.acksPending && Objects.equals(responseStatus, that.responseStatus);
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(requiredOffset, responseStatus, acksPending);
+        }
+    }
+
+    private static final class DelayedProduceMetrics {

Review Comment:
   I see. Fixed.



-- 
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]

Reply via email to