mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-03 02:52:08 +08:00
[Optimize]Connector增改接口的configs字段名调整为config (#1080)
1、保持和原生一致; 2、当前是兼容状态,可同时支持configs和config;
This commit is contained in:
@@ -49,9 +49,9 @@ public class ConnectorManagerImpl implements ConnectorManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Void> createConnector(ConnectorCreateDTO dto, String operator) {
|
public Result<Void> createConnector(ConnectorCreateDTO dto, String operator) {
|
||||||
dto.getConfigs().put(KafkaConnectConstant.MIRROR_MAKER_NAME_FIELD_NAME, dto.getConnectorName());
|
dto.getSuitableConfig().put(KafkaConnectConstant.MIRROR_MAKER_NAME_FIELD_NAME, dto.getConnectorName());
|
||||||
|
|
||||||
Result<KSConnectorInfo> createResult = connectorService.createConnector(dto.getConnectClusterId(), dto.getConnectorName(), dto.getConfigs(), operator);
|
Result<KSConnectorInfo> createResult = connectorService.createConnector(dto.getConnectClusterId(), dto.getConnectorName(), dto.getSuitableConfig(), operator);
|
||||||
if (createResult.failed()) {
|
if (createResult.failed()) {
|
||||||
return Result.buildFromIgnoreData(createResult);
|
return Result.buildFromIgnoreData(createResult);
|
||||||
}
|
}
|
||||||
@@ -67,9 +67,9 @@ public class ConnectorManagerImpl implements ConnectorManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Void> createConnector(ConnectorCreateDTO dto, String heartbeatName, String checkpointName, String operator) {
|
public Result<Void> createConnector(ConnectorCreateDTO dto, String heartbeatName, String checkpointName, String operator) {
|
||||||
dto.getConfigs().put(KafkaConnectConstant.MIRROR_MAKER_NAME_FIELD_NAME, dto.getConnectorName());
|
dto.getSuitableConfig().put(KafkaConnectConstant.MIRROR_MAKER_NAME_FIELD_NAME, dto.getConnectorName());
|
||||||
|
|
||||||
Result<KSConnectorInfo> createResult = connectorService.createConnector(dto.getConnectClusterId(), dto.getConnectorName(), dto.getConfigs(), operator);
|
Result<KSConnectorInfo> createResult = connectorService.createConnector(dto.getConnectClusterId(), dto.getConnectorName(), dto.getSuitableConfig(), operator);
|
||||||
if (createResult.failed()) {
|
if (createResult.failed()) {
|
||||||
return Result.buildFromIgnoreData(createResult);
|
return Result.buildFromIgnoreData(createResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,17 +132,17 @@ public class MirrorMakerManagerImpl implements MirrorMakerManager {
|
|||||||
} else if (checkpointResult.failed() && checkpointResult.failed()) {
|
} else if (checkpointResult.failed() && checkpointResult.failed()) {
|
||||||
return Result.buildFromRSAndMsg(
|
return Result.buildFromRSAndMsg(
|
||||||
ResultStatus.KAFKA_CONNECTOR_OPERATE_FAILED,
|
ResultStatus.KAFKA_CONNECTOR_OPERATE_FAILED,
|
||||||
String.format("创建 checkpoint & heartbeat 失败.\n失败信息分别为:%s\n\n%s", checkpointResult.getMessage(), heartbeatResult.getMessage())
|
String.format("创建 checkpoint & heartbeat 失败.%n失败信息分别为:%s%n%n%s", checkpointResult.getMessage(), heartbeatResult.getMessage())
|
||||||
);
|
);
|
||||||
} else if (checkpointResult.failed()) {
|
} else if (checkpointResult.failed()) {
|
||||||
return Result.buildFromRSAndMsg(
|
return Result.buildFromRSAndMsg(
|
||||||
ResultStatus.KAFKA_CONNECTOR_OPERATE_FAILED,
|
ResultStatus.KAFKA_CONNECTOR_OPERATE_FAILED,
|
||||||
String.format("创建 checkpoint 失败.\n失败信息分别为:%s", checkpointResult.getMessage())
|
String.format("创建 checkpoint 失败.%n失败信息分别为:%s", checkpointResult.getMessage())
|
||||||
);
|
);
|
||||||
} else{
|
} else{
|
||||||
return Result.buildFromRSAndMsg(
|
return Result.buildFromRSAndMsg(
|
||||||
ResultStatus.KAFKA_CONNECTOR_OPERATE_FAILED,
|
ResultStatus.KAFKA_CONNECTOR_OPERATE_FAILED,
|
||||||
String.format("创建 heartbeat 失败.\n失败信息分别为:%s", heartbeatResult.getMessage())
|
String.format("创建 heartbeat 失败.%n失败信息分别为:%s", heartbeatResult.getMessage())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ public class MirrorMakerManagerImpl implements MirrorMakerManager {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
return connectorService.updateConnectorConfig(dto.getConnectClusterId(), dto.getConnectorName(), dto.getConfigs(), operator);
|
return connectorService.updateConnectorConfig(dto.getConnectClusterId(), dto.getConnectorName(), dto.getSuitableConfig(), operator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -426,7 +426,7 @@ public class MirrorMakerManagerImpl implements MirrorMakerManager {
|
|||||||
public Result<List<ConnectConfigInfosVO>> validateConnectors(MirrorMakerCreateDTO dto) {
|
public Result<List<ConnectConfigInfosVO>> validateConnectors(MirrorMakerCreateDTO dto) {
|
||||||
List<ConnectConfigInfosVO> voList = new ArrayList<>();
|
List<ConnectConfigInfosVO> voList = new ArrayList<>();
|
||||||
|
|
||||||
Result<ConnectConfigInfos> infoResult = pluginService.validateConfig(dto.getConnectClusterId(), dto.getConfigs());
|
Result<ConnectConfigInfos> infoResult = pluginService.validateConfig(dto.getConnectClusterId(), dto.getSuitableConfig());
|
||||||
if (infoResult.failed()) {
|
if (infoResult.failed()) {
|
||||||
return Result.buildFromIgnoreData(infoResult);
|
return Result.buildFromIgnoreData(infoResult);
|
||||||
}
|
}
|
||||||
@@ -480,11 +480,11 @@ public class MirrorMakerManagerImpl implements MirrorMakerManager {
|
|||||||
return Result.buildFromRSAndMsg(ResultStatus.CLUSTER_NOT_EXIST, MsgConstant.getClusterPhyNotExist(connectCluster.getKafkaClusterPhyId()));
|
return Result.buildFromRSAndMsg(ResultStatus.CLUSTER_NOT_EXIST, MsgConstant.getClusterPhyNotExist(connectCluster.getKafkaClusterPhyId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dto.getConfigs().containsKey(CONNECTOR_CLASS_FILED_NAME)) {
|
if (!dto.getSuitableConfig().containsKey(CONNECTOR_CLASS_FILED_NAME)) {
|
||||||
return Result.buildFromRSAndMsg(ResultStatus.PARAM_ILLEGAL, "SourceConnector缺少connector.class");
|
return Result.buildFromRSAndMsg(ResultStatus.PARAM_ILLEGAL, "SourceConnector缺少connector.class");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MIRROR_MAKER_SOURCE_CONNECTOR_TYPE.equals(dto.getConfigs().getProperty(CONNECTOR_CLASS_FILED_NAME))) {
|
if (!MIRROR_MAKER_SOURCE_CONNECTOR_TYPE.equals(dto.getSuitableConfig().getProperty(CONNECTOR_CLASS_FILED_NAME))) {
|
||||||
return Result.buildFromRSAndMsg(ResultStatus.PARAM_ILLEGAL, "SourceConnector的connector.class类型错误");
|
return Result.buildFromRSAndMsg(ResultStatus.PARAM_ILLEGAL, "SourceConnector的connector.class类型错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,9 +589,7 @@ public class MirrorMakerManagerImpl implements MirrorMakerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
voList.forEach(elem -> {
|
voList.forEach(elem -> elem.setMetricLines(metricLineMap.get(elem.getConnectClusterId() + "#" + elem.getConnectorName())));
|
||||||
elem.setMetricLines(metricLineMap.get(elem.getConnectClusterId() + "#" + elem.getConnectorName()));
|
|
||||||
});
|
|
||||||
|
|
||||||
return voList;
|
return voList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.xiaojukeji.know.streaming.km.common.bean.dto.connect.connector;
|
package com.xiaojukeji.know.streaming.km.common.bean.dto.connect.connector;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.xiaojukeji.know.streaming.km.common.bean.dto.connect.ClusterConnectorDTO;
|
import com.xiaojukeji.know.streaming.km.common.bean.dto.connect.ClusterConnectorDTO;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,15 +14,23 @@ import java.util.Properties;
|
|||||||
* @date 2022-10-17
|
* @date 2022-10-17
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ApiModel(description = "创建Connector")
|
@ApiModel(description = "创建Connector")
|
||||||
public class ConnectorCreateDTO extends ClusterConnectorDTO {
|
public class ConnectorCreateDTO extends ClusterConnectorDTO {
|
||||||
@NotNull(message = "configs不允许为空")
|
@Deprecated
|
||||||
@ApiModelProperty(value = "配置", example = "")
|
@ApiModelProperty(value = "配置, 优先使用config字段,3.5.0版本将删除该字段", example = "")
|
||||||
protected Properties configs;
|
protected Properties configs;
|
||||||
|
|
||||||
public ConnectorCreateDTO(Long connectClusterId, String connectorName, Properties configs) {
|
@ApiModelProperty(value = "配置", example = "")
|
||||||
|
protected Properties config;
|
||||||
|
|
||||||
|
public ConnectorCreateDTO(Long connectClusterId, String connectorName, Properties config) {
|
||||||
super(connectClusterId, connectorName);
|
super(connectClusterId, connectorName);
|
||||||
this.configs = configs;
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties getSuitableConfig() {
|
||||||
|
return config != null? config: configs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class MirrorMakerCreateDTO extends ConnectorCreateDTO {
|
|||||||
targetKafkaProps = new Properties();
|
targetKafkaProps = new Properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unifyData(this.configs, sourceKafkaClusterId, sourceBootstrapServers, sourceKafkaProps, targetKafkaClusterId, targetBootstrapServers, targetKafkaProps);
|
this.unifyData(this.getSuitableConfig(), sourceKafkaClusterId, sourceBootstrapServers, sourceKafkaProps, targetKafkaClusterId, targetBootstrapServers, targetKafkaProps);
|
||||||
|
|
||||||
if (heartbeatConnectorConfigs != null) {
|
if (heartbeatConnectorConfigs != null) {
|
||||||
this.unifyData(this.heartbeatConnectorConfigs, sourceKafkaClusterId, sourceBootstrapServers, sourceKafkaProps, targetKafkaClusterId, targetBootstrapServers, targetKafkaProps);
|
this.unifyData(this.heartbeatConnectorConfigs, sourceKafkaClusterId, sourceBootstrapServers, sourceKafkaProps, targetKafkaClusterId, targetBootstrapServers, targetKafkaProps);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
@ApiModel(description = "集群MM2状态信息")
|
@ApiModel(description = "集群MM2状态信息")
|
||||||
public class MirrorMakerBaseStateVO extends BaseVO {
|
public class MirrorMakerBaseStateVO extends BaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "worker数", example = "1")
|
@ApiModelProperty(value = "worker数", example = "1")
|
||||||
private Integer workerCount;
|
private Integer workerCount;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.xiaojukeji.know.streaming.km.common.constant.ApiPrefix;
|
|||||||
import com.xiaojukeji.know.streaming.km.common.constant.Constant;
|
import com.xiaojukeji.know.streaming.km.common.constant.Constant;
|
||||||
import com.xiaojukeji.know.streaming.km.common.enums.connect.ConnectActionEnum;
|
import com.xiaojukeji.know.streaming.km.common.enums.connect.ConnectActionEnum;
|
||||||
import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil;
|
import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil;
|
||||||
|
import com.xiaojukeji.know.streaming.km.common.utils.ValidateUtils;
|
||||||
import com.xiaojukeji.know.streaming.km.core.service.connect.connector.ConnectorService;
|
import com.xiaojukeji.know.streaming.km.core.service.connect.connector.ConnectorService;
|
||||||
import com.xiaojukeji.know.streaming.km.core.service.connect.plugin.PluginService;
|
import com.xiaojukeji.know.streaming.km.core.service.connect.plugin.PluginService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -44,6 +45,10 @@ public class KafkaConnectorController {
|
|||||||
@PostMapping(value = "connectors")
|
@PostMapping(value = "connectors")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<Void> createConnector(@Validated @RequestBody ConnectorCreateDTO dto) {
|
public Result<Void> createConnector(@Validated @RequestBody ConnectorCreateDTO dto) {
|
||||||
|
if (ValidateUtils.isNull(dto.getSuitableConfig())) {
|
||||||
|
return Result.buildFromRSAndMsg(ResultStatus.PARAM_ILLEGAL, "config字段不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
return connectorManager.createConnector(dto, HttpRequestUtil.getOperator());
|
return connectorManager.createConnector(dto, HttpRequestUtil.getOperator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,14 +78,27 @@ public class KafkaConnectorController {
|
|||||||
@PutMapping(value ="connectors-config")
|
@PutMapping(value ="connectors-config")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<Void> modifyConnectors(@Validated @RequestBody ConnectorCreateDTO dto) {
|
public Result<Void> modifyConnectors(@Validated @RequestBody ConnectorCreateDTO dto) {
|
||||||
return connectorManager.updateConnectorConfig(dto.getConnectClusterId(), dto.getConnectorName(), dto.getConfigs(), HttpRequestUtil.getOperator());
|
if (ValidateUtils.isNull(dto.getSuitableConfig())) {
|
||||||
|
return Result.buildFromRSAndMsg(ResultStatus.PARAM_ILLEGAL, "config字段不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectorManager.updateConnectorConfig(
|
||||||
|
dto.getConnectClusterId(),
|
||||||
|
dto.getConnectorName(),
|
||||||
|
dto.getSuitableConfig(),
|
||||||
|
HttpRequestUtil.getOperator()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "校验Connector配置", notes = "")
|
@ApiOperation(value = "校验Connector配置", notes = "")
|
||||||
@PutMapping(value ="connectors-config/validate")
|
@PutMapping(value ="connectors-config/validate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<ConnectConfigInfosVO> validateConnectors(@Validated @RequestBody ConnectorCreateDTO dto) {
|
public Result<ConnectConfigInfosVO> validateConnectors(@Validated @RequestBody ConnectorCreateDTO dto) {
|
||||||
Result<ConnectConfigInfos> infoResult = pluginService.validateConfig(dto.getConnectClusterId(), dto.getConfigs());
|
if (ValidateUtils.isNull(dto.getSuitableConfig())) {
|
||||||
|
return Result.buildFromRSAndMsg(ResultStatus.PARAM_ILLEGAL, "config字段不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<ConnectConfigInfos> infoResult = pluginService.validateConfig(dto.getConnectClusterId(), dto.getSuitableConfig());
|
||||||
if (infoResult.failed()) {
|
if (infoResult.failed()) {
|
||||||
return Result.buildFromIgnoreData(infoResult);
|
return Result.buildFromIgnoreData(infoResult);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user