This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new c2f7dcc6b2a Fix UnregisterStorageUnitExecutor compile error (#30035)
c2f7dcc6b2a is described below
commit c2f7dcc6b2af5115b5c704e99aec26d9f552a7b2
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Feb 7 12:17:13 2024 +0800
Fix UnregisterStorageUnitExecutor compile error (#30035)
---
.../rdl/resource/UnregisterStorageUnitExecutor.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitExecutor.java
index dec03eeb9e8..c280285e230 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/resource/UnregisterStorageUnitExecutor.java
@@ -38,6 +38,7 @@ import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.Map;
import java.util.stream.Collectors;
@@ -77,20 +78,25 @@ public final class UnregisterStorageUnitExecutor implements
DistSQLUpdateExecuto
if (inUsedStorageUnitNames.isEmpty()) {
return;
}
- Collection<Class<? extends ShardingSphereRule>>
ignoreShardingSphereRules = getIgnoreShardingSphereRules(sqlStatement);
+ Collection<Class<ShardingSphereRule>> ignoreShardingSphereRules =
getIgnoreShardingSphereRules(sqlStatement);
String firstResource = inUsedStorageUnitNames.iterator().next();
ShardingSpherePreconditions.checkState(!ignoreShardingSphereRules.isEmpty(), ()
-> new StorageUnitInUsedException(firstResource,
inUsedStorageUnits.get(firstResource)));
checkInUsedIgnoreTables(new HashSet<>(inUsedStorageUnitNames),
inUsedStorageUnits, ignoreShardingSphereRules);
}
- @SuppressWarnings("unchecked")
- private Collection<Class<? extends ShardingSphereRule>>
getIgnoreShardingSphereRules(final UnregisterStorageUnitStatement sqlStatement)
{
- return
ShardingSphereServiceLoader.getServiceInstances(StorageUnitDefinitionProcessor.class).stream()
- .filter(each ->
each.ignoreUsageCheckOnUnregister(sqlStatement)).map(StorageUnitDefinitionProcessor::getRule).collect(Collectors.toList());
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private Collection<Class<ShardingSphereRule>>
getIgnoreShardingSphereRules(final UnregisterStorageUnitStatement sqlStatement)
{
+ Collection<Class<ShardingSphereRule>> result = new LinkedList<>();
+ for (StorageUnitDefinitionProcessor each :
ShardingSphereServiceLoader.getServiceInstances(StorageUnitDefinitionProcessor.class))
{
+ if (each.ignoreUsageCheckOnUnregister(sqlStatement)) {
+ result.add(each.getRule());
+ }
+ }
+ return result;
}
private void checkInUsedIgnoreTables(final Collection<String>
inUsedResourceNames, final Map<String, Collection<Class<? extends
ShardingSphereRule>>> inUsedStorageUnits,
- final Collection<Class<? extends
ShardingSphereRule>> ignoreShardingSphereRules) {
+ final
Collection<Class<ShardingSphereRule>> ignoreShardingSphereRules) {
for (String each : inUsedResourceNames) {
Collection<Class<? extends ShardingSphereRule>> inUsedRules =
inUsedStorageUnits.get(each);
ignoreShardingSphereRules.forEach(inUsedRules::remove);