[Optimize]优化Connector创建时的入参

1、增加config.action.reload的默认值;
2、增加errors.tolerance的默认值;
This commit is contained in:
zengqiao
2022-12-14 14:12:32 +08:00
parent 896a943587
commit 7db757bc12
2 changed files with 17 additions and 3 deletions

View File

@@ -7,8 +7,10 @@ import lombok.NoArgsConstructor;
import org.apache.kafka.connect.runtime.rest.entities.ConfigInfo;
import org.apache.kafka.connect.runtime.rest.entities.ConfigInfos;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import static com.xiaojukeji.know.streaming.km.common.constant.Constant.CONNECTOR_CONFIG_ACTION_RELOAD_NAME;
import static com.xiaojukeji.know.streaming.km.common.constant.Constant.CONNECTOR_CONFIG_ERRORS_TOLERANCE_NAME;
/**
* @see ConfigInfos
@@ -17,6 +19,13 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
public class ConnectConfigInfos {
private static final Map<String, List<String>> recommendValuesMap = new HashMap<>();
static {
recommendValuesMap.put(CONNECTOR_CONFIG_ACTION_RELOAD_NAME, Arrays.asList("none", "restart"));
recommendValuesMap.put(CONNECTOR_CONFIG_ERRORS_TOLERANCE_NAME, Arrays.asList("none", "all"));
}
private String name;
private int errorCount;
@@ -48,7 +57,7 @@ public class ConnectConfigInfos {
ConnectConfigValueInfo value = new ConnectConfigValueInfo();
value.setName(configInfo.configValue().name());
value.setValue(configInfo.configValue().value());
value.setRecommendedValues(configInfo.configValue().recommendedValues());
value.setRecommendedValues(recommendValuesMap.getOrDefault(configInfo.configValue().name(), configInfo.configValue().recommendedValues()));
value.setErrors(configInfo.configValue().errors());
value.setVisible(configInfo.configValue().visible());

View File

@@ -65,4 +65,9 @@ public class Constant {
public static final Integer DEFAULT_RETRY_TIME = 3;
public static final Integer ZK_ALIVE_BUT_4_LETTER_FORBIDDEN = 11;
public static final String CONNECTOR_CONFIG_ACTION_RELOAD_NAME = "config.action.reload";
public static final String CONNECTOR_CONFIG_ERRORS_TOLERANCE_NAME = "errors.tolerance";
}