Merge remote-tracking branch 'origin/kafka' into kafka
正在显示
3 个修改的文件
包含
19 行增加
和
1 行删除
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*; | @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*; | ||
13 | import javax.annotation.Resource; | 13 | import javax.annotation.Resource; |
14 | import java.io.IOException; | 14 | import java.io.IOException; |
15 | import java.util.List; | 15 | import java.util.List; |
16 | +import java.util.concurrent.ExecutionException; | ||
16 | import java.util.concurrent.TimeoutException; | 17 | import java.util.concurrent.TimeoutException; |
17 | 18 | ||
18 | import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_QUEUE_INFO; | 19 | import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_QUEUE_INFO; |
@@ -110,10 +111,11 @@ public class BusQueueController { | @@ -110,10 +111,11 @@ public class BusQueueController { | ||
110 | * @return {@link ResultJson} | 111 | * @return {@link ResultJson} |
111 | */ | 112 | */ |
112 | @PutMapping("/update") | 113 | @PutMapping("/update") |
113 | - public ResultJson updateBusQueue(@RequestBody BusQueue busQueue) | 114 | + public ResultJson updateBusQueue(@RequestBody BusQueue busQueue)throws ExecutionException, InterruptedException |
114 | { | 115 | { |
115 | // 先校验队列名称 | 116 | // 先校验队列名称 |
116 | String message = validateBusQueue(busQueue); | 117 | String message = validateBusQueue(busQueue); |
118 | + kafkaService.ediPartition(busQueue); | ||
117 | return message == null | 119 | return message == null |
118 | ? busQueueService.updateByPrimaryKeySelective(busQueue) > 0 | 120 | ? busQueueService.updateByPrimaryKeySelective(busQueue) > 0 |
119 | ? new ResultJson<>("200", "编辑MQ消息队列信息,成功") | 121 | ? new ResultJson<>("200", "编辑MQ消息队列信息,成功") |
1 | package com.sunyo.wlpt.message.bus.service.service; | 1 | package com.sunyo.wlpt.message.bus.service.service; |
2 | 2 | ||
3 | +import com.sunyo.wlpt.message.bus.service.domain.BusQueue; | ||
3 | import com.sunyo.wlpt.message.bus.service.model.ConsumerGroupOffsets; | 4 | import com.sunyo.wlpt.message.bus.service.model.ConsumerGroupOffsets; |
4 | 5 | ||
5 | import java.util.List; | 6 | import java.util.List; |
7 | +import java.util.concurrent.ExecutionException; | ||
6 | 8 | ||
7 | public interface KafkaService { | 9 | public interface KafkaService { |
8 | 10 | ||
@@ -15,6 +17,8 @@ public interface KafkaService { | @@ -15,6 +17,8 @@ public interface KafkaService { | ||
15 | boolean addTopic(String TopicName,int partitionNum); | 17 | boolean addTopic(String TopicName,int partitionNum); |
16 | 18 | ||
17 | public void updateAdminclient(); | 19 | public void updateAdminclient(); |
20 | + //by xyh | ||
21 | + boolean ediPartition(BusQueue record)throws ExecutionException, InterruptedException; | ||
18 | 22 | ||
19 | /** | 23 | /** |
20 | * topic信息消费状况监控监控 | 24 | * topic信息消费状况监控监控 |
1 | package com.sunyo.wlpt.message.bus.service.service.kafka; | 1 | package com.sunyo.wlpt.message.bus.service.service.kafka; |
2 | 2 | ||
3 | 3 | ||
4 | +import com.sunyo.wlpt.message.bus.service.domain.BusQueue; | ||
4 | import com.sunyo.wlpt.message.bus.service.domain.BusServer; | 5 | import com.sunyo.wlpt.message.bus.service.domain.BusServer; |
5 | import com.sunyo.wlpt.message.bus.service.mapper.BusServerMapper; | 6 | import com.sunyo.wlpt.message.bus.service.mapper.BusServerMapper; |
6 | import com.sunyo.wlpt.message.bus.service.mapper.ConsumerGroupMapper; | 7 | import com.sunyo.wlpt.message.bus.service.mapper.ConsumerGroupMapper; |
@@ -86,6 +87,17 @@ public class KafkaServiceImp implements KafkaService { | @@ -86,6 +87,17 @@ public class KafkaServiceImp implements KafkaService { | ||
86 | KafkaAdmin admin = new KafkaAdmin(configs); | 87 | KafkaAdmin admin = new KafkaAdmin(configs); |
87 | KAFKA_ADMIN_CLIENT = AdminClient.create(admin.getConfig()); | 88 | KAFKA_ADMIN_CLIENT = AdminClient.create(admin.getConfig()); |
88 | } | 89 | } |
90 | + | ||
91 | + @Override | ||
92 | + public boolean ediPartition(BusQueue record) throws ExecutionException, InterruptedException{ | ||
93 | + Map<String, NewPartitions> newPartitions = new HashMap<>(); | ||
94 | + // 将MyTopic的Partition数量调整为2 | ||
95 | + newPartitions.put(record.getQueueName(), NewPartitions.increaseTo(record.getPartitionCount())); | ||
96 | + CreatePartitionsResult result = KAFKA_ADMIN_CLIENT.createPartitions(newPartitions); | ||
97 | + System.out.println(result.all().get()); | ||
98 | + return true; | ||
99 | + } | ||
100 | + | ||
89 | /** | 101 | /** |
90 | * 获取topicList | 102 | * 获取topicList |
91 | */ | 103 | */ |
-
请 注册 或 登录 后发表评论