-
Notifications
You must be signed in to change notification settings - Fork 120
alter rmq replicator unnecessary validation #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,22 +208,22 @@ public Class<? extends Task> taskClass() { | |
| return ReplicatorSourceTask.class; | ||
| } | ||
|
|
||
| private Set<String> neededParamKeys = new HashSet<String>() { | ||
| private Map<String, Boolean> neededParamKeys = new HashMap<String, Boolean>() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No test changes are included for the altered validation behavior. Since this changes which configuration keys are required versus optional for the source connector, tests should cover both the required-field rejection path and the newly-optional-field acceptance path. |
||
| { | ||
| add(ReplicatorConnectorConfig.SRC_CLOUD); | ||
| add(ReplicatorConnectorConfig.SRC_REGION); | ||
| add(ReplicatorConnectorConfig.SRC_CLUSTER); | ||
| add(ReplicatorConnectorConfig.SRC_ENDPOINT); | ||
| add(ReplicatorConnectorConfig.SRC_TOPICTAGS); | ||
| add(ReplicatorConnectorConfig.DEST_CLOUD); | ||
| add(ReplicatorConnectorConfig.DEST_REGION); | ||
| add(ReplicatorConnectorConfig.DEST_CLUSTER); | ||
| add(ReplicatorConnectorConfig.DEST_ENDPOINT); | ||
| add(ReplicatorConnectorConfig.DEST_TOPIC); | ||
| add(ReplicatorConnectorConfig.SRC_CLOUD); | ||
| add(ReplicatorConnectorConfig.SRC_ACL_ENABLE); | ||
| add(ReplicatorConnectorConfig.DEST_ACL_ENABLE); | ||
| add(ERRORS_TOLERANCE_CONFIG); | ||
| put(ReplicatorConnectorConfig.SRC_CLOUD, false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is not a necessary parameter, can you consider removing it from the verification?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is also possible to remove them directly, but it is easier for me to extend or customize them. It would be better to extract the required parameters into a unified public class rather than write them for each connector
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, after the connector is implemented, the necessary configuration has been determined. In the subsequent evolution and development, of course, it is possible to challenge the verification rules of these parameters, but it is a very low-frequency operation. For example, we have some differences now. However, after our discussion this time, after confirming those that are indeed required and those that are not, there may be basically no major changes. |
||
| put(ReplicatorConnectorConfig.SRC_REGION, false); | ||
| put(ReplicatorConnectorConfig.SRC_CLUSTER, false); | ||
| put(ReplicatorConnectorConfig.SRC_ENDPOINT, true); | ||
| put(ReplicatorConnectorConfig.SRC_TOPICTAGS, true); | ||
| put(ReplicatorConnectorConfig.DEST_CLOUD, false); | ||
| put(ReplicatorConnectorConfig.DEST_REGION, false); | ||
| put(ReplicatorConnectorConfig.DEST_CLUSTER, false); | ||
| put(ReplicatorConnectorConfig.DEST_ENDPOINT, true); | ||
| put(ReplicatorConnectorConfig.DEST_TOPIC, true); | ||
| put(ReplicatorConnectorConfig.SRC_CLOUD, false); | ||
| put(ReplicatorConnectorConfig.SRC_ACL_ENABLE, false); | ||
| put(ReplicatorConnectorConfig.DEST_ACL_ENABLE, false); | ||
| put(ERRORS_TOLERANCE_CONFIG, false); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -239,7 +239,7 @@ public void validate(KeyValue config) { | |
| ReplicatorUtils.checkNeedParams(ReplicatorSourceConnector.class.getName(), config, neededParamKeys); | ||
| String consumeFromWhere = config.getString(ReplicatorConnectorConfig.CONSUME_FROM_WHERE, ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET.name()); | ||
| if (StringUtils.isNotBlank(consumeFromWhere) && consumeFromWhere.equals(ConsumeFromWhere.CONSUME_FROM_TIMESTAMP.name())) { | ||
| ReplicatorUtils.checkNeedParamNotEmpty(ReplicatorSourceConnector.class.getName(), config, ReplicatorConnectorConfig.CONSUME_FROM_TIMESTAMP); | ||
| ReplicatorUtils.checkNeedParamNotEmpty(ReplicatorSourceConnector.class.getName(), config, ReplicatorConnectorConfig.CONSUME_FROM_TIMESTAMP, true); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,14 +63,14 @@ public static String buildConsumergroupWithNamespace(String consumerGroup, Strin | |
| return instanceId + "%" + consumerGroup; | ||
| } | ||
|
|
||
| public static void checkNeedParams(String connectorName, KeyValue config, Set<String> neededParamKeys) { | ||
| for (String needParamKey : neededParamKeys) { | ||
| checkNeedParamNotEmpty(connectorName, config, needParamKey); | ||
| public static void checkNeedParams(String connectorName, KeyValue config, Map<String, Boolean> neededParamKeys) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The public method signatures of checkNeedParams and checkNeedParamNotEmpty were changed (Set -> Map<String, Boolean> and added boolean parameter). This is a breaking API change for any external callers of these public utility methods. If backward compatibility is required, consider adding overloaded methods that preserve the old signatures. |
||
| for (String needParamKey : neededParamKeys.keySet()) { | ||
| checkNeedParamNotEmpty(connectorName, config, needParamKey, neededParamKeys.get(needParamKey)); | ||
| } | ||
| } | ||
|
|
||
| public static void checkNeedParamNotEmpty(String connectorName, KeyValue config, String needParamKey) { | ||
| if (StringUtils.isEmpty(config.getString(needParamKey, ""))) { | ||
| public static void checkNeedParamNotEmpty(String connectorName, KeyValue config, String needParamKey, boolean isNeeded) { | ||
| if (StringUtils.isEmpty(config.getString(needParamKey, "")) && isNeeded) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the new isNeeded flag, configuration parameters marked false skip emptiness validation entirely. Ensure that every parameter marked false truly has a safe runtime default or is genuinely optional; otherwise missing/empty values may cause runtime failures downstream rather than failing fast during validation. |
||
| log.error("Replicator connector " + connectorName + " do not set " + needParamKey); | ||
| throw new ParamInvalidException("Replicator connector " + connectorName + " do not set " + needParamKey); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ParamInvalidException message was shortened to only include the param key, dropping the connector name and 'do not set' context. This makes error messages less actionable and is inconsistent with the preceding log.error() call that still logs the full message. Consider keeping the original full exception message. |
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test changes detected alongside source modifications. Consider adding tests to cover the changes.