Skip to content

Commit 97a9362

Browse files
author
duanxiaoqiu
committed
[Feature]增加Truncate数据功能(didi#1043)
1 parent 5a38899 commit 97a9362

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

km-core/src/main/java/com/xiaojukeji/know/streaming/km/core/service/topic/impl/OpTopicServiceImpl.java

+3-23
Original file line numberDiff line numberDiff line change
@@ -210,31 +210,11 @@ public Result<Void> expandTopic(TopicPartitionExpandParam expandParam, String op
210210
@Override
211211
public Result<Void> truncateTopic(TopicParam param, String operator) {
212212
try {
213+
// 清空topic数据
213214
Result<Void> rv = (Result<Void>) doVCHandler(param.getClusterPhyId(), TOPIC_TRUNCATE, param);
214-
if (rv.failed()) {
215-
return rv;
216-
}
217-
218-
// 删除DB中的Topic数据
219-
topicService.deleteTopicInDB(param.getClusterPhyId(), param.getTopicName());
220215

221-
//解除高可用Topic关联
222-
List<HaActiveStandbyRelation> haActiveStandbyRelations = haActiveStandbyRelationService.listByClusterAndType(param.getClusterPhyId(), HaResTypeEnum.MIRROR_TOPIC);
223-
for (HaActiveStandbyRelation activeStandbyRelation : haActiveStandbyRelations) {
224-
if (activeStandbyRelation.getResName().equals(param.getTopicName())) {
225-
try {
226-
KafkaZkClient kafkaZkClient = kafkaAdminZKClient.getClient(activeStandbyRelation.getStandbyClusterPhyId());
227-
Properties haTopics = kafkaZkClient.getEntityConfigs("ha-topics", activeStandbyRelation.getResName());
228-
if (haTopics.size() != 0) {
229-
kafkaZkClient.setOrCreateEntityConfigs("ha-topics", activeStandbyRelation.getResName(), new Properties());
230-
kafkaZkClient.createConfigChangeNotification("ha-topics/" + activeStandbyRelation.getResName());
231-
}
232-
haActiveStandbyRelationService.batchDeleteTopicHA(activeStandbyRelation.getActiveClusterPhyId(), activeStandbyRelation.getStandbyClusterPhyId(), Collections.singletonList(activeStandbyRelation.getResName()));
233-
} catch (Exception e) {
234-
log.error("method=truncateTopic||topicName:{}||errMsg=exception", activeStandbyRelation.getResName(), e);
235-
return Result.buildFailure(e.getMessage());
236-
}
237-
}
216+
if (rv == null || rv.failed()) {
217+
return rv;
238218
}
239219

240220
// 记录操作

0 commit comments

Comments
 (0)