mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-10 00:42:07 +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.clients.admin.ElectLeadersResult;
|
||||||
import org.apache.kafka.common.ElectionType;
|
import org.apache.kafka.common.ElectionType;
|
||||||
import org.apache.kafka.common.TopicPartition;
|
import org.apache.kafka.common.TopicPartition;
|
||||||
|
import org.apache.kafka.common.errors.ElectionNotNeededException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import scala.jdk.javaapi.CollectionConverters;
|
import scala.jdk.javaapi.CollectionConverters;
|
||||||
@@ -108,12 +109,17 @@ public class OpPartitionServiceImpl extends BaseKafkaVersionControlService imple
|
|||||||
|
|
||||||
return Result.buildSuc();
|
return Result.buildSuc();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
if(e.getCause() instanceof ElectionNotNeededException) {
|
||||||
|
// ignore ElectionNotNeededException
|
||||||
|
return Result.buildSuc();
|
||||||
|
}
|
||||||
|
|
||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
"method=preferredReplicaElectionByKafkaClient||clusterPhyId={}||errMsg=exception",
|
"method=preferredReplicaElectionByKafkaClient||clusterPhyId={}||errMsg=exception",
|
||||||
partitionParam.getClusterPhyId(), e
|
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