You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2025/01/16 11:39:22 UTC
(kafka) branch 4.0 updated: KAFKA-18406 Remove ZkBrokerEpochManager.scala (#18561)
This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/4.0 by this push:
new f333f9f340f KAFKA-18406 Remove ZkBrokerEpochManager.scala (#18561)
f333f9f340f is described below
commit f333f9f340f5633cd59f7346b8da7bd77eca0cce
Author: Ken Huang <s7...@gmail.com>
AuthorDate: Thu Jan 16 19:35:09 2025 +0800
KAFKA-18406 Remove ZkBrokerEpochManager.scala (#18561)
Reviewers: Chia-Ping Tsai <ch...@gmail.com>
---
.../scala/kafka/server/ZkBrokerEpochManager.scala | 52 ----------------------
1 file changed, 52 deletions(-)
diff --git a/core/src/main/scala/kafka/server/ZkBrokerEpochManager.scala b/core/src/main/scala/kafka/server/ZkBrokerEpochManager.scala
deleted file mode 100644
index 36b28154445..00000000000
--- a/core/src/main/scala/kafka/server/ZkBrokerEpochManager.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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 kafka.server
-
-import kafka.controller.KafkaController
-import org.apache.kafka.common.requests.AbstractControlRequest
-
-class ZkBrokerEpochManager(metadataCache: MetadataCache,
- controller: KafkaController,
- lifecycleManagerOpt: Option[BrokerLifecycleManager]) {
- def get(): Long = {
- lifecycleManagerOpt match {
- case Some(lifecycleManager) => metadataCache.getControllerId match {
- case Some(_: ZkCachedControllerId) => controller.brokerEpoch
- case Some(_: KRaftCachedControllerId) => lifecycleManager.brokerEpoch
- case None => controller.brokerEpoch
- }
- case None => controller.brokerEpoch
- }
- }
-
- def isBrokerEpochStale(brokerEpochInRequest: Long, isKRaftControllerRequest: Boolean): Boolean = {
- if (brokerEpochInRequest == AbstractControlRequest.UNKNOWN_BROKER_EPOCH) {
- false
- } else if (isKRaftControllerRequest) {
- if (lifecycleManagerOpt.isDefined) {
- brokerEpochInRequest < lifecycleManagerOpt.get.brokerEpoch
- } else {
- throw new IllegalStateException("Expected BrokerLifecycleManager to be non-null.")
- }
- } else {
- // brokerEpochInRequest > controller.brokerEpoch is possible in rare scenarios where the controller gets notified
- // about the new broker epoch and sends a control request with this epoch before the broker learns about it
- brokerEpochInRequest < controller.brokerEpoch
- }
- }
-}