Skip to content

Commit 7db757b

Browse files
author
zengqiao
committed
[Optimize]优化Connector创建时的入参
1、增加config.action.reload的默认值; 2、增加errors.tolerance的默认值;
1 parent 896a943 commit 7db757b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

km-common/src/main/java/com/xiaojukeji/know/streaming/km/common/bean/entity/connect/config/ConnectConfigInfos.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import org.apache.kafka.connect.runtime.rest.entities.ConfigInfo;
88
import org.apache.kafka.connect.runtime.rest.entities.ConfigInfos;
99

10-
import java.util.ArrayList;
11-
import java.util.List;
10+
import java.util.*;
11+
12+
import static com.xiaojukeji.know.streaming.km.common.constant.Constant.CONNECTOR_CONFIG_ACTION_RELOAD_NAME;
13+
import static com.xiaojukeji.know.streaming.km.common.constant.Constant.CONNECTOR_CONFIG_ERRORS_TOLERANCE_NAME;
1214

1315
/**
1416
* @see ConfigInfos
@@ -17,6 +19,13 @@
1719
@NoArgsConstructor
1820
@AllArgsConstructor
1921
public class ConnectConfigInfos {
22+
23+
private static final Map<String, List<String>> recommendValuesMap = new HashMap<>();
24+
25+
static {
26+
recommendValuesMap.put(CONNECTOR_CONFIG_ACTION_RELOAD_NAME, Arrays.asList("none", "restart"));
27+
recommendValuesMap.put(CONNECTOR_CONFIG_ERRORS_TOLERANCE_NAME, Arrays.asList("none", "all"));
28+
}
2029
private String name;
2130

2231
private int errorCount;
@@ -48,7 +57,7 @@ public ConnectConfigInfos(ConfigInfos configInfos) {
4857
ConnectConfigValueInfo value = new ConnectConfigValueInfo();
4958
value.setName(configInfo.configValue().name());
5059
value.setValue(configInfo.configValue().value());
51-
value.setRecommendedValues(configInfo.configValue().recommendedValues());
60+
value.setRecommendedValues(recommendValuesMap.getOrDefault(configInfo.configValue().name(), configInfo.configValue().recommendedValues()));
5261
value.setErrors(configInfo.configValue().errors());
5362
value.setVisible(configInfo.configValue().visible());
5463

km-common/src/main/java/com/xiaojukeji/know/streaming/km/common/constant/Constant.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,9 @@ private Constant() {}
6565
public static final Integer DEFAULT_RETRY_TIME = 3;
6666

6767
public static final Integer ZK_ALIVE_BUT_4_LETTER_FORBIDDEN = 11;
68+
69+
public static final String CONNECTOR_CONFIG_ACTION_RELOAD_NAME = "config.action.reload";
70+
71+
public static final String CONNECTOR_CONFIG_ERRORS_TOLERANCE_NAME = "errors.tolerance";
72+
6873
}

0 commit comments

Comments
 (0)