Skip to content

Commit c3dde6e

Browse files
authored
feat(zerozone2): return NOT_LEADER_OR_FOLLOWER to stale produce (#2931)
Signed-off-by: Robin Han <[email protected]>
1 parent dd690be commit c3dde6e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/src/main/java/kafka/automq/zerozone/ZeroZoneTrafficInterceptor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
import org.apache.kafka.common.message.AutomqZoneRouterRequestData;
3434
import org.apache.kafka.common.message.MetadataResponseData;
3535
import org.apache.kafka.common.message.ProduceRequestData;
36+
import org.apache.kafka.common.protocol.Errors;
3637
import org.apache.kafka.common.record.MemoryRecords;
38+
import org.apache.kafka.common.requests.ProduceResponse;
3739
import org.apache.kafka.common.requests.s3.AutomqZoneRouterResponse;
3840
import org.apache.kafka.common.utils.LogContext;
3941
import org.apache.kafka.common.utils.Time;
@@ -154,6 +156,13 @@ public void close() {
154156

155157
@Override
156158
public void handleProduceRequest(ProduceRequestArgs args) {
159+
if (closed.get()) {
160+
Map<TopicPartition, ProduceResponse.PartitionResponse> responseMap = new HashMap<>(args.entriesPerPartition().size());
161+
args.entriesPerPartition().forEach((tp, records) ->
162+
responseMap.put(tp, new ProduceResponse.PartitionResponse(Errors.NOT_LEADER_OR_FOLLOWER)));
163+
args.responseCallback().accept(responseMap);
164+
return;
165+
}
157166
ClientIdMetadata clientId = args.clientId();
158167
fillRackIfMissing(clientId);
159168
if (version.isZeroZoneV2Supported()) {

0 commit comments

Comments
 (0)