mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 20:22:12 +08:00
[bugfix]leader重选时忽略ElectionNotNeededException异常,返回成功
This commit is contained in:
@@ -19,6 +19,7 @@ import org.apache.kafka.clients.admin.ElectLeadersOptions;
|
||||
import org.apache.kafka.clients.admin.ElectLeadersResult;
|
||||
import org.apache.kafka.common.ElectionType;
|
||||
import org.apache.kafka.common.TopicPartition;
|
||||
import org.apache.kafka.common.errors.ElectionNotNeededException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import scala.jdk.javaapi.CollectionConverters;
|
||||
@@ -108,12 +109,17 @@ public class OpPartitionServiceImpl extends BaseKafkaVersionControlService imple
|
||||
|
||||
return Result.buildSuc();
|
||||
} catch (Exception e) {
|
||||
if(e.getCause() instanceof ElectionNotNeededException) {
|
||||
// ignore ElectionNotNeededException
|
||||
return Result.buildSuc();
|
||||
}
|
||||
|
||||
LOGGER.error(
|
||||
"method=preferredReplicaElectionByKafkaClient||clusterPhyId={}||errMsg=exception",
|
||||
partitionParam.getClusterPhyId(), e
|
||||
);
|
||||
|
||||
return Result.buildFromRSAndMsg(ResultStatus.ZK_OPERATE_FAILED, e.getMessage());
|
||||
return Result.buildFromRSAndMsg(ResultStatus.KAFKA_OPERATE_FAILED, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user