This is an automated email from the ASF dual-hosted git repository.

zhaojinchao 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 a4be9bf57c1 Fix SPI type conflict in Encrypt DistSQL (#27915)
a4be9bf57c1 is described below

commit a4be9bf57c104364533dd1022e1692fe533988b3
Author: Raigor <[email protected]>
AuthorDate: Fri Aug 4 16:01:09 2023 +0800

    Fix SPI type conflict in Encrypt DistSQL (#27915)
---
 ...AlterCompatibleEncryptRuleStatementUpdater.java | 61 -------------
 ...reateCompatibleEncryptRuleStatementUpdater.java | 61 -------------
 .../DropCompatibleEncryptRuleStatementUpdater.java | 99 ----------------------
 ...re.distsql.handler.update.RuleDefinitionUpdater |  3 -
 4 files changed, 224 deletions(-)

diff --git 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterCompatibleEncryptRuleStatementUpdater.java
 
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterCompatibleEncryptRuleStatementUpdater.java
deleted file mode 100644
index 958924088d6..00000000000
--- 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterCompatibleEncryptRuleStatementUpdater.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.encrypt.distsql.handler.update;
-
-import 
org.apache.shardingsphere.distsql.handler.update.RuleDefinitionAlterUpdater;
-import 
org.apache.shardingsphere.encrypt.api.config.CompatibleEncryptRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-
-/**
- * Alter encrypt rule statement updater.
- * 
- * @deprecated Should use new api, compatible api will remove in next version.
- */
-@Deprecated
-public final class AlterCompatibleEncryptRuleStatementUpdater implements 
RuleDefinitionAlterUpdater<AlterEncryptRuleStatement, 
CompatibleEncryptRuleConfiguration> {
-    
-    private final AlterEncryptRuleStatementUpdater delegate = new 
AlterEncryptRuleStatementUpdater();
-    
-    @Override
-    public void checkSQLStatement(final ShardingSphereDatabase database, final 
AlterEncryptRuleStatement sqlStatement, final 
CompatibleEncryptRuleConfiguration currentRuleConfig) {
-        delegate.checkSQLStatement(database, sqlStatement, 
currentRuleConfig.convertToEncryptRuleConfiguration());
-    }
-    
-    @Override
-    public CompatibleEncryptRuleConfiguration 
buildToBeAlteredRuleConfiguration(final AlterEncryptRuleStatement sqlStatement) 
{
-        EncryptRuleConfiguration ruleConfig = 
delegate.buildToBeAlteredRuleConfiguration(sqlStatement);
-        return new CompatibleEncryptRuleConfiguration(ruleConfig.getTables(), 
ruleConfig.getEncryptors());
-    }
-    
-    @Override
-    public void updateCurrentRuleConfiguration(final 
CompatibleEncryptRuleConfiguration currentRuleConfig, final 
CompatibleEncryptRuleConfiguration toBeAlteredRuleConfig) {
-        
delegate.updateCurrentRuleConfiguration(currentRuleConfig.convertToEncryptRuleConfiguration(),
 toBeAlteredRuleConfig.convertToEncryptRuleConfiguration());
-    }
-    
-    @Override
-    public Class<CompatibleEncryptRuleConfiguration> 
getRuleConfigurationClass() {
-        return CompatibleEncryptRuleConfiguration.class;
-    }
-    
-    @Override
-    public String getType() {
-        return AlterEncryptRuleStatement.class.getName();
-    }
-}
diff --git 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateCompatibleEncryptRuleStatementUpdater.java
 
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateCompatibleEncryptRuleStatementUpdater.java
deleted file mode 100644
index 267aa586ad4..00000000000
--- 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateCompatibleEncryptRuleStatementUpdater.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.encrypt.distsql.handler.update;
-
-import 
org.apache.shardingsphere.distsql.handler.update.RuleDefinitionCreateUpdater;
-import 
org.apache.shardingsphere.encrypt.api.config.CompatibleEncryptRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-
-/**
- * Create encrypt rule statement updater.
- * 
- * @deprecated Should use new api, compatible api will remove in next version.
- */
-@Deprecated
-public final class CreateCompatibleEncryptRuleStatementUpdater implements 
RuleDefinitionCreateUpdater<CreateEncryptRuleStatement, 
CompatibleEncryptRuleConfiguration> {
-    
-    private final CreateEncryptRuleStatementUpdater delegate = new 
CreateEncryptRuleStatementUpdater();
-    
-    @Override
-    public void checkSQLStatement(final ShardingSphereDatabase database, final 
CreateEncryptRuleStatement sqlStatement, final 
CompatibleEncryptRuleConfiguration currentRuleConfig) {
-        delegate.checkSQLStatement(database, sqlStatement, 
currentRuleConfig.convertToEncryptRuleConfiguration());
-    }
-    
-    @Override
-    public CompatibleEncryptRuleConfiguration 
buildToBeCreatedRuleConfiguration(final CompatibleEncryptRuleConfiguration 
currentRuleConfig, final CreateEncryptRuleStatement sqlStatement) {
-        EncryptRuleConfiguration ruleConfig = 
delegate.buildToBeCreatedRuleConfiguration(currentRuleConfig.convertToEncryptRuleConfiguration(),
 sqlStatement);
-        return new CompatibleEncryptRuleConfiguration(ruleConfig.getTables(), 
ruleConfig.getEncryptors());
-    }
-    
-    @Override
-    public void updateCurrentRuleConfiguration(final 
CompatibleEncryptRuleConfiguration currentRuleConfig, final 
CompatibleEncryptRuleConfiguration toBeCreatedRuleConfig) {
-        
delegate.updateCurrentRuleConfiguration(currentRuleConfig.convertToEncryptRuleConfiguration(),
 toBeCreatedRuleConfig.convertToEncryptRuleConfiguration());
-    }
-    
-    @Override
-    public Class<CompatibleEncryptRuleConfiguration> 
getRuleConfigurationClass() {
-        return CompatibleEncryptRuleConfiguration.class;
-    }
-    
-    @Override
-    public String getType() {
-        return CreateEncryptRuleStatement.class.getName();
-    }
-}
diff --git 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropCompatibleEncryptRuleStatementUpdater.java
 
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropCompatibleEncryptRuleStatementUpdater.java
deleted file mode 100644
index c679f31fc19..00000000000
--- 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropCompatibleEncryptRuleStatementUpdater.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.encrypt.distsql.handler.update;
-
-import 
org.apache.shardingsphere.distsql.handler.update.RuleDefinitionDropUpdater;
-import 
org.apache.shardingsphere.encrypt.api.config.CompatibleEncryptRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.distsql.parser.statement.DropEncryptRuleStatement;
-import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-/**
- * Drop encrypt rule statement updater.
- * 
- * @deprecated Should use new api, compatible api will remove in next version.
- */
-@Deprecated
-public final class DropCompatibleEncryptRuleStatementUpdater implements 
RuleDefinitionDropUpdater<DropEncryptRuleStatement, 
CompatibleEncryptRuleConfiguration> {
-    
-    private final DropEncryptRuleStatementUpdater delegate = new 
DropEncryptRuleStatementUpdater();
-    
-    @Override
-    public void checkSQLStatement(final ShardingSphereDatabase database, final 
DropEncryptRuleStatement sqlStatement, final CompatibleEncryptRuleConfiguration 
currentRuleConfig) {
-        delegate.checkSQLStatement(database, sqlStatement, 
currentRuleConfig.convertToEncryptRuleConfiguration());
-    }
-    
-    @Override
-    public boolean hasAnyOneToBeDropped(final DropEncryptRuleStatement 
sqlStatement, final CompatibleEncryptRuleConfiguration currentRuleConfig) {
-        return delegate.hasAnyOneToBeDropped(sqlStatement, 
currentRuleConfig.convertToEncryptRuleConfiguration());
-    }
-    
-    @Override
-    public CompatibleEncryptRuleConfiguration 
buildToBeDroppedRuleConfiguration(final CompatibleEncryptRuleConfiguration 
currentRuleConfig, final DropEncryptRuleStatement sqlStatement) {
-        Collection<EncryptTableRuleConfiguration> toBeDroppedTables = new 
LinkedList<>();
-        Map<String, AlgorithmConfiguration> toBeDroppedEncryptors = new 
HashMap<>();
-        for (String each : sqlStatement.getTables()) {
-            toBeDroppedTables.add(new EncryptTableRuleConfiguration(each, 
Collections.emptyList()));
-            dropRule(currentRuleConfig, each);
-        }
-        findUnusedEncryptors(currentRuleConfig).forEach(each -> 
toBeDroppedEncryptors.put(each, currentRuleConfig.getEncryptors().get(each)));
-        return new CompatibleEncryptRuleConfiguration(toBeDroppedTables, 
toBeDroppedEncryptors);
-    }
-    
-    private void dropRule(final CompatibleEncryptRuleConfiguration 
currentRuleConfig, final String ruleName) {
-        Optional<EncryptTableRuleConfiguration> encryptTableRuleConfig = 
currentRuleConfig.getTables().stream().filter(each -> 
each.getName().equals(ruleName)).findAny();
-        encryptTableRuleConfig.ifPresent(optional -> 
currentRuleConfig.getTables().remove(encryptTableRuleConfig.get()));
-    }
-    
-    private static Collection<String> findUnusedEncryptors(final 
CompatibleEncryptRuleConfiguration currentRuleConfig) {
-        Collection<String> inUsedEncryptors = 
currentRuleConfig.getTables().stream().flatMap(each -> 
each.getColumns().stream()).map(optional -> 
optional.getCipher().getEncryptorName())
-                .collect(Collectors.toSet());
-        
inUsedEncryptors.addAll(currentRuleConfig.getTables().stream().flatMap(each -> 
each.getColumns().stream())
-                .map(optional -> 
optional.getAssistedQuery().map(EncryptColumnItemRuleConfiguration::getEncryptorName).orElse(""))
-                .collect(Collectors.toSet()));
-        
inUsedEncryptors.addAll(currentRuleConfig.getTables().stream().flatMap(each -> 
each.getColumns().stream())
-                .map(optional -> 
optional.getLikeQuery().map(EncryptColumnItemRuleConfiguration::getEncryptorName).orElse(""))
-                .collect(Collectors.toSet()));
-        return currentRuleConfig.getEncryptors().keySet().stream().filter(each 
-> !inUsedEncryptors.contains(each)).collect(Collectors.toSet());
-    }
-    
-    @Override
-    public boolean updateCurrentRuleConfiguration(final 
DropEncryptRuleStatement sqlStatement, final CompatibleEncryptRuleConfiguration 
currentRuleConfig) {
-        return delegate.updateCurrentRuleConfiguration(sqlStatement, 
currentRuleConfig.convertToEncryptRuleConfiguration());
-    }
-    
-    @Override
-    public Class<CompatibleEncryptRuleConfiguration> 
getRuleConfigurationClass() {
-        return CompatibleEncryptRuleConfiguration.class;
-    }
-    
-    @Override
-    public String getType() {
-        return DropEncryptRuleStatement.class.getName();
-    }
-}
diff --git 
a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.update.RuleDefinitionUpdater
 
b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.update.RuleDefinitionUpdater
index 67b99d902c4..0151ebedc0a 100644
--- 
a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.update.RuleDefinitionUpdater
+++ 
b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.update.RuleDefinitionUpdater
@@ -16,8 +16,5 @@
 #
 
 
org.apache.shardingsphere.encrypt.distsql.handler.update.CreateEncryptRuleStatementUpdater
-org.apache.shardingsphere.encrypt.distsql.handler.update.CreateCompatibleEncryptRuleStatementUpdater
 
org.apache.shardingsphere.encrypt.distsql.handler.update.AlterEncryptRuleStatementUpdater
-org.apache.shardingsphere.encrypt.distsql.handler.update.AlterCompatibleEncryptRuleStatementUpdater
 
org.apache.shardingsphere.encrypt.distsql.handler.update.DropEncryptRuleStatementUpdater
-org.apache.shardingsphere.encrypt.distsql.handler.update.DropCompatibleEncryptRuleStatementUpdater

Reply via email to