限流配置
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.xuxd.kafka.console.beans.dto;
|
||||
|
||||
import com.xuxd.kafka.console.beans.enums.ThrottleUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* kafka-console-ui.
|
||||
*
|
||||
* @author xuxd
|
||||
* @date 2021-11-24 19:37:10
|
||||
**/
|
||||
@Data
|
||||
public class BrokerThrottleDTO {
|
||||
|
||||
private List<Integer> brokerList = new ArrayList<>();
|
||||
|
||||
private long throttle;
|
||||
|
||||
private ThrottleUnit unit;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xuxd.kafka.console.beans.enums;
|
||||
|
||||
/**
|
||||
* kafka-console-ui.
|
||||
*
|
||||
* @author xuxd
|
||||
* @date 2021-11-24 19:38:00
|
||||
**/
|
||||
public enum ThrottleUnit {
|
||||
KB, MB;
|
||||
|
||||
public long toKb(long size) {
|
||||
if (this == MB) {
|
||||
return 1024 * size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xuxd.kafka.console.controller;
|
||||
|
||||
import com.xuxd.kafka.console.beans.dto.BrokerThrottleDTO;
|
||||
import com.xuxd.kafka.console.beans.dto.ReplicationDTO;
|
||||
import com.xuxd.kafka.console.beans.dto.SyncDataDTO;
|
||||
import com.xuxd.kafka.console.service.OperationService;
|
||||
@@ -52,4 +53,9 @@ public class OperationController {
|
||||
public Object electPreferredLeader(@RequestBody ReplicationDTO dto) {
|
||||
return operationService.electPreferredLeader(dto.getTopic(), dto.getPartition());
|
||||
}
|
||||
|
||||
@PostMapping("/broker/throttle")
|
||||
public Object configThrottle(@RequestBody BrokerThrottleDTO dto) {
|
||||
return operationService.configThrottle(dto.getBrokerList(), dto.getUnit().toKb(dto.getThrottle()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xuxd.kafka.console.service;
|
||||
|
||||
import com.xuxd.kafka.console.beans.ResponseData;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -20,4 +21,6 @@ public interface OperationService {
|
||||
ResponseData deleteAlignmentById(Long id);
|
||||
|
||||
ResponseData electPreferredLeader(String topic, int partition);
|
||||
|
||||
ResponseData configThrottle(List<Integer> brokerList, long size);
|
||||
}
|
||||
|
||||
@@ -123,4 +123,10 @@ public class OperationServiceImpl implements OperationService {
|
||||
|
||||
return (boolean) tuple2._1() ? ResponseData.create().success() : ResponseData.create().failed(tuple2._2());
|
||||
}
|
||||
|
||||
@Override public ResponseData configThrottle(List<Integer> brokerList, long size) {
|
||||
Tuple2<Object, String> tuple2 = operationConsole.modifyInterBrokerThrottle(new HashSet<>(brokerList), size);
|
||||
|
||||
return (boolean) tuple2._1() ? ResponseData.create().success() : ResponseData.create().failed(tuple2._2());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user