Pace2Car commented on code in PR #24688:
URL: https://github.com/apache/shardingsphere/pull/24688#discussion_r1141828113
##########
kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdater.java:
##########
@@ -59,21 +58,10 @@ private Collection<String> getNotExistRuleNames(final
TrafficRuleConfiguration c
}
private void checkAlgorithmNames(final AlterTrafficRuleStatement
sqlStatement) {
- Collection<String> invalidAlgorithmNames =
getInvalidAlgorithmNames(sqlStatement);
-
ShardingSpherePreconditions.checkState(invalidAlgorithmNames.isEmpty(), () ->
new InvalidAlgorithmConfigurationException("Traffic", invalidAlgorithmNames));
- }
-
- private Collection<String> getInvalidAlgorithmNames(final
AlterTrafficRuleStatement sqlStatement) {
- Collection<String> result = new LinkedList<>();
- for (TrafficRuleSegment each : sqlStatement.getSegments()) {
- if (!TypedSPILoader.contains(TrafficAlgorithm.class,
each.getAlgorithm().getName())) {
- result.add(each.getAlgorithm().getName());
- }
- if (null != each.getLoadBalancer() &&
!TypedSPILoader.contains(TrafficLoadBalanceAlgorithm.class,
each.getLoadBalancer().getName())) {
- result.add(each.getLoadBalancer().getName());
- }
- }
- return result;
+ sqlStatement.getSegments().forEach(each -> {
+ TypedSPILoader.checkService(TrafficAlgorithm.class,
each.getAlgorithm().getName(), each.getAlgorithm().getProps());
+ TypedSPILoader.checkService(TrafficLoadBalanceAlgorithm.class,
each.getLoadBalancer().getName(), each.getLoadBalancer().getProps());
Review Comment:
Fixed, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]