mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-01 09:42:11 +08:00
version 2.3.0
This commit is contained in:
@@ -50,7 +50,7 @@ public class GatewayHeartbeatController {
|
||||
doList = JsonUtils.parseTopicConnections(clusterId, jsonObject, System.currentTimeMillis());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("class=GatewayHeartbeatController||method=receiveTopicConnections||clusterId={}||brokerId={}||msg=parse data failed||exception={}", clusterId, brokerId, e.getMessage());
|
||||
return Result.buildFailure("fail");
|
||||
return Result.buildGatewayFailure("fail");
|
||||
}
|
||||
|
||||
topicConnectionService.batchAdd(doList);
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequestMapping(ApiPrefix.GATEWAY_API_V1_PREFIX)
|
||||
public class GatewayServiceDiscoveryController {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(GatewayHeartbeatController.class);
|
||||
|
||||
@Autowired
|
||||
@@ -65,7 +64,7 @@ public class GatewayServiceDiscoveryController {
|
||||
KafkaBootstrapServerConfig config =
|
||||
gatewayConfigService.getKafkaBootstrapServersConfig(Long.MIN_VALUE);
|
||||
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getClusterIdBootstrapServersMap())) {
|
||||
return Result.buildFailure("call init kafka bootstrap servers failed");
|
||||
return Result.buildGatewayFailure("call init kafka bootstrap servers failed");
|
||||
}
|
||||
if (ValidateUtils.isEmptyMap(config.getClusterIdBootstrapServersMap())) {
|
||||
return Result.buildSuc();
|
||||
@@ -81,7 +80,7 @@ public class GatewayServiceDiscoveryController {
|
||||
KafkaBootstrapServerConfig config =
|
||||
gatewayConfigService.getKafkaBootstrapServersConfig(versionNumber);
|
||||
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getClusterIdBootstrapServersMap())) {
|
||||
return Result.buildFailure("call update kafka bootstrap servers failed");
|
||||
return Result.buildGatewayFailure("call update kafka bootstrap servers failed");
|
||||
}
|
||||
if (ValidateUtils.isEmptyMap(config.getClusterIdBootstrapServersMap())) {
|
||||
return Result.buildSuc();
|
||||
@@ -99,7 +98,7 @@ public class GatewayServiceDiscoveryController {
|
||||
public Result<String> getMaxRequestNum(@RequestParam("versionNumber") long versionNumber) {
|
||||
RequestQueueConfig config = gatewayConfigService.getRequestQueueConfig(versionNumber);
|
||||
if (ValidateUtils.isNull(config)) {
|
||||
return Result.buildFailure("call get request queue size config failed");
|
||||
return Result.buildGatewayFailure("call get request queue size config failed");
|
||||
}
|
||||
if (ValidateUtils.isNull(config.getMaxRequestQueueSize())) {
|
||||
return Result.buildSuc();
|
||||
@@ -119,7 +118,7 @@ public class GatewayServiceDiscoveryController {
|
||||
public Result<String> getAppIdRate(@RequestParam("versionNumber") long versionNumber) {
|
||||
AppRateConfig config = gatewayConfigService.getAppRateConfig(versionNumber);
|
||||
if (ValidateUtils.isNull(config)) {
|
||||
return Result.buildFailure("call get app rate config failed");
|
||||
return Result.buildGatewayFailure("call get app rate config failed");
|
||||
}
|
||||
if (ValidateUtils.isNull(config.getAppRateLimit())) {
|
||||
return Result.buildSuc();
|
||||
@@ -139,7 +138,7 @@ public class GatewayServiceDiscoveryController {
|
||||
public Result getIpRate(@RequestParam("versionNumber") long versionNumber) {
|
||||
IpRateConfig config = gatewayConfigService.getIpRateConfig(versionNumber);
|
||||
if (ValidateUtils.isNull(config)) {
|
||||
return Result.buildFailure("call get ip rate config failed");
|
||||
return Result.buildGatewayFailure("call get ip rate config failed");
|
||||
}
|
||||
if (ValidateUtils.isNull(config.getIpRateLimit())) {
|
||||
return Result.buildSuc();
|
||||
@@ -160,7 +159,7 @@ public class GatewayServiceDiscoveryController {
|
||||
SpRateConfig config =
|
||||
gatewayConfigService.getSpRateConfig(versionNumber);
|
||||
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getSpRateMap())) {
|
||||
return Result.buildFailure("call update kafka bootstrap servers failed");
|
||||
return Result.buildGatewayFailure("call update kafka bootstrap servers failed");
|
||||
}
|
||||
if (ValidateUtils.isEmptyMap(config.getSpRateMap())) {
|
||||
return Result.buildSuc();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xiaojukeji.kafka.manager.web.api.versionone.op;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.op.ControllerPreferredCandidateDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.rd.ClusterDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
||||
@@ -13,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/4/23
|
||||
@@ -25,48 +27,56 @@ public class OpClusterController {
|
||||
private ClusterService clusterService;
|
||||
|
||||
@ApiOperation(value = "接入集群")
|
||||
@RequestMapping(value = "clusters", method = RequestMethod.POST)
|
||||
@PostMapping(value = "clusters")
|
||||
@ResponseBody
|
||||
public Result addNew(@RequestBody ClusterDTO dto) {
|
||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
return Result.buildFrom(
|
||||
clusterService.addNew(
|
||||
ClusterModelConverter.convert2ClusterDO(dto),
|
||||
SpringTool.getUserName()
|
||||
)
|
||||
clusterService.addNew(ClusterModelConverter.convert2ClusterDO(dto), SpringTool.getUserName())
|
||||
);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除集群")
|
||||
@RequestMapping(value = "clusters", method = RequestMethod.DELETE)
|
||||
@DeleteMapping(value = "clusters")
|
||||
@ResponseBody
|
||||
public Result delete(@RequestParam(value = "clusterId") Long clusterId) {
|
||||
return Result.buildFrom(clusterService.deleteById(clusterId, SpringTool.getUserName()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改集群信息")
|
||||
@RequestMapping(value = "clusters", method = RequestMethod.PUT)
|
||||
@PutMapping(value = "clusters")
|
||||
@ResponseBody
|
||||
public Result modify(@RequestBody ClusterDTO reqObj) {
|
||||
if (ValidateUtils.isNull(reqObj) || !reqObj.legal() || ValidateUtils.isNull(reqObj.getClusterId())) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
ResultStatus rs = clusterService.updateById(
|
||||
ClusterModelConverter.convert2ClusterDO(reqObj),
|
||||
SpringTool.getUserName()
|
||||
return Result.buildFrom(
|
||||
clusterService.updateById(ClusterModelConverter.convert2ClusterDO(reqObj), SpringTool.getUserName())
|
||||
);
|
||||
return Result.buildFrom(rs);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "开启|关闭集群监控")
|
||||
@RequestMapping(value = "clusters/{clusterId}/monitor", method = RequestMethod.PUT)
|
||||
@PutMapping(value = "clusters/{clusterId}/monitor")
|
||||
@ResponseBody
|
||||
public Result modifyStatus(@PathVariable Long clusterId,
|
||||
@RequestParam("status") Integer status) {
|
||||
public Result modifyStatus(@PathVariable Long clusterId, @RequestParam("status") Integer status) {
|
||||
return Result.buildFrom(
|
||||
clusterService.modifyStatus(clusterId, status, SpringTool.getUserName())
|
||||
);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "增加Controller优先候选的Broker", notes = "滴滴内部引擎特性")
|
||||
@PostMapping(value = "cluster-controller/preferred-candidates")
|
||||
@ResponseBody
|
||||
public Result addControllerPreferredCandidates(@RequestBody ControllerPreferredCandidateDTO dto) {
|
||||
return clusterService.addControllerPreferredCandidates(dto.getClusterId(), dto.getBrokerIdList());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除Controller优先候选的Broker", notes = "滴滴内部引擎特性")
|
||||
@DeleteMapping(value = "cluster-controller/preferred-candidates")
|
||||
@ResponseBody
|
||||
public Result deleteControllerPreferredCandidates(@RequestBody ControllerPreferredCandidateDTO dto) {
|
||||
return clusterService.deleteControllerPreferredCandidates(dto.getClusterId(), dto.getBrokerIdList());
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,11 @@ package com.xiaojukeji.kafka.manager.web.api.versionone.op;
|
||||
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionAddGatewayConfigDTO;
|
||||
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionDeleteGatewayConfigDTO;
|
||||
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionModifyGatewayConfigDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.gateway.GatewayConfigKeyEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.service.service.gateway.GatewayConfigService;
|
||||
import com.xiaojukeji.kafka.manager.web.converters.GatewayModelConverter;
|
||||
@@ -16,12 +19,20 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Api(tags = "OP-Gateway配置相关接口(REST)")
|
||||
@RestController
|
||||
@RequestMapping(ApiPrefix.API_V1_OP_PREFIX)
|
||||
public class OpGatewayConfigController {
|
||||
@Autowired
|
||||
private GatewayConfigService gatewayConfigService;
|
||||
|
||||
@ApiOperation(value = "Gateway配置类型", notes = "")
|
||||
@GetMapping(value = "gateway-configs/type-enums")
|
||||
@ResponseBody
|
||||
public Result getClusterModesEnum() {
|
||||
return new Result<>(JsonUtils.toJson(GatewayConfigKeyEnum.class));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "创建Gateway配置", notes = "")
|
||||
@RequestMapping(value = "gateway-configs", method = RequestMethod.POST)
|
||||
@PostMapping(value = "gateway-configs")
|
||||
@ResponseBody
|
||||
public Result createGatewayConfig(@RequestBody OrderExtensionAddGatewayConfigDTO dto) {
|
||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||
@@ -31,7 +42,7 @@ public class OpGatewayConfigController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改Gateway配置", notes = "")
|
||||
@RequestMapping(value = "gateway-configs", method = RequestMethod.PUT)
|
||||
@PutMapping(value = "gateway-configs")
|
||||
@ResponseBody
|
||||
public Result modifyGatewayConfig(@RequestBody OrderExtensionModifyGatewayConfigDTO dto) {
|
||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||
@@ -41,7 +52,7 @@ public class OpGatewayConfigController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除Gateway配置", notes = "")
|
||||
@RequestMapping(value = "gateway-configs", method = RequestMethod.DELETE)
|
||||
@DeleteMapping(value = "gateway-configs")
|
||||
@ResponseBody
|
||||
public Result deleteGatewayConfig(@RequestBody OrderExtensionDeleteGatewayConfigDTO dto) {
|
||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xiaojukeji.kafka.manager.web.api.versionone.rd;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.vo.rd.GatewayConfigVO;
|
||||
@@ -15,12 +16,13 @@ import java.util.List;
|
||||
|
||||
@Api(tags = "RD-Gateway配置相关接口(REST)")
|
||||
@RestController
|
||||
@RequestMapping(ApiPrefix.API_V1_RD_PREFIX)
|
||||
public class RdGatewayConfigController {
|
||||
@Autowired
|
||||
private GatewayConfigService gatewayConfigService;
|
||||
|
||||
@ApiOperation(value = "Gateway相关配置信息", notes = "")
|
||||
@RequestMapping(value = "gateway-configs", method = RequestMethod.GET)
|
||||
@GetMapping(value = "gateway-configs")
|
||||
@ResponseBody
|
||||
public Result<List<GatewayConfigVO>> getGatewayConfigs() {
|
||||
List<GatewayConfigDO> doList = gatewayConfigService.list();
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.xiaojukeji.kafka.manager.web.api.versionone.rd;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaFileEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.KafkaFileDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.vo.rd.KafkaFileVO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.storage.common.StorageEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
||||
import com.xiaojukeji.kafka.manager.kcm.KafkaFileService;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.SpringTool;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.kcm.KafkaFileService;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.storage.common.StorageEnum;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
||||
import com.xiaojukeji.kafka.manager.web.converters.KafkaFileConverter;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -24,14 +24,13 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping(ApiPrefix.API_V1_RD_PREFIX)
|
||||
public class RdOperateRecordController {
|
||||
|
||||
private static final int MAX_RECORD_COUNT = 200;
|
||||
|
||||
@Autowired
|
||||
private OperateRecordService operateRecordService;
|
||||
|
||||
@ApiOperation(value = "查询操作记录", notes = "")
|
||||
@RequestMapping(value = "operate-record", method = RequestMethod.POST)
|
||||
@PostMapping(value = "operate-record")
|
||||
@ResponseBody
|
||||
public Result<List<OperateRecordVO>> geOperateRecords(@RequestBody OperateRecordDTO dto) {
|
||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||
|
||||
@@ -67,6 +67,7 @@ public class GatewayModelConverter {
|
||||
vo.setName(configDO.getName());
|
||||
vo.setValue(configDO.getValue());
|
||||
vo.setVersion(configDO.getVersion());
|
||||
vo.setDescription(configDO.getDescription());
|
||||
vo.setCreateTime(configDO.getCreateTime());
|
||||
vo.setModifyTime(configDO.getModifyTime());
|
||||
voList.add(vo);
|
||||
@@ -76,18 +77,20 @@ public class GatewayModelConverter {
|
||||
|
||||
public static GatewayConfigDO convert2GatewayConfigDO(OrderExtensionAddGatewayConfigDTO configDTO) {
|
||||
GatewayConfigDO configDO = new GatewayConfigDO();
|
||||
configDO.setType(configDO.getType());
|
||||
configDO.setName(configDO.getName());
|
||||
configDO.setValue(configDO.getValue());
|
||||
configDO.setType(configDTO.getType());
|
||||
configDO.setName(configDTO.getName());
|
||||
configDO.setValue(configDTO.getValue());
|
||||
configDO.setDescription(ValidateUtils.isNull(configDTO.getDescription())? "": configDTO.getDescription());
|
||||
return configDO;
|
||||
}
|
||||
|
||||
public static GatewayConfigDO convert2GatewayConfigDO(OrderExtensionModifyGatewayConfigDTO configDTO) {
|
||||
GatewayConfigDO configDO = new GatewayConfigDO();
|
||||
configDO.setId(configDO.getId());
|
||||
configDO.setType(configDO.getType());
|
||||
configDO.setName(configDO.getName());
|
||||
configDO.setValue(configDO.getValue());
|
||||
configDO.setId(configDTO.getId());
|
||||
configDO.setType(configDTO.getType());
|
||||
configDO.setName(configDTO.getName());
|
||||
configDO.setValue(configDTO.getValue());
|
||||
configDO.setDescription(ValidateUtils.isNull(configDTO.getDescription())? "": configDTO.getDescription());
|
||||
return configDO;
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class WebMetricsInterceptor {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
String uri = attributes.getRequest().getRequestURI();
|
||||
if (uri.contains(ApiPrefix.GATEWAY_API_V1_PREFIX)) {
|
||||
return Result.buildFailure("api limited");
|
||||
return Result.buildGatewayFailure("api limited");
|
||||
}
|
||||
return new Result<>(ResultStatus.OPERATION_FORBIDDEN);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user