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 501fef51b2b Remove unused scaling subscriber and preprocessor (#20485)
501fef51b2b is described below

commit 501fef51b2b0521368dc269474c48f908501a98b
Author: Xinze Guo <[email protected]>
AuthorDate: Wed Aug 24 16:03:25 2022 +0800

    Remove unused scaling subscriber and preprocessor (#20485)
---
 ...lterShardingTableRuleStatementPreprocessor.java | 60 ---------------
 .../RuleDefinitionAlterPreprocessor.java           | 40 ----------
 .../RuleDefinitionAlterPreprocessorFactory.java    | 48 ------------
 ...RuleDefinitionAlterPreprocessorFactoryTest.java | 39 ----------
 .../FixtureRuleDefinitionAlterPreprocessor.java    | 33 --------
 .../cluster/coordinator/RegistryCenter.java        |  2 -
 .../registry/cache/event/StartScalingEvent.java    | 45 -----------
 .../subscriber/ScalingRegistrySubscriber.java      | 89 ----------------------
 .../event/rule/ScalingTaskFinishedEvent.java       | 39 ----------
 .../version/MetadataVersionPreparedEvent.java      | 35 ---------
 .../subscriber/ScalingRegistrySubscriberTest.java  | 79 -------------------
 .../rdl/rule/RuleDefinitionBackendHandler.java     | 36 ---------
 .../jaxb/cases/domain/SQLParserTestCases.java      |  2 +-
 13 files changed, 1 insertion(+), 546 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/preprocess/AlterShardingTableRuleStatementPreprocessor.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/preprocess/AlterShardingTableRuleStatementPrepro
 [...]
deleted file mode 100644
index 3973fadcacf..00000000000
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/preprocess/AlterShardingTableRuleStatementPreprocessor.java
+++ /dev/null
@@ -1,60 +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.sharding.distsql.handler.preprocess;
-
-import 
org.apache.shardingsphere.infra.distsql.preprocess.RuleDefinitionAlterPreprocessor;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingTableRuleStatement;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-
-/**
- * Alter sharding table rule statement preprocessor.
- */
-public final class AlterShardingTableRuleStatementPreprocessor implements 
RuleDefinitionAlterPreprocessor<ShardingRuleConfiguration> {
-    
-    @Override
-    public ShardingRuleConfiguration preprocess(final 
ShardingRuleConfiguration currentRuleConfig, final ShardingRuleConfiguration 
toBeAlteredRuleConfig) {
-        ShardingRuleConfiguration result = new ShardingRuleConfiguration();
-        result.setShardingAlgorithms(new 
HashMap<>(currentRuleConfig.getShardingAlgorithms()));
-        result.setAutoTables(new 
LinkedList<>(currentRuleConfig.getAutoTables()));
-        
result.setDefaultShardingColumn(currentRuleConfig.getDefaultShardingColumn());
-        
result.setDefaultTableShardingStrategy(currentRuleConfig.getDefaultTableShardingStrategy());
-        result.setBindingTableGroups(new 
LinkedList<>(currentRuleConfig.getBindingTableGroups()));
-        
result.setDefaultDatabaseShardingStrategy(currentRuleConfig.getDefaultDatabaseShardingStrategy());
-        result.setTables(new LinkedList<>(currentRuleConfig.getTables()));
-        result.setBroadcastTables(new 
LinkedList<>(currentRuleConfig.getBroadcastTables()));
-        
result.setDefaultKeyGenerateStrategy(getKeyGenerateStrategyConfiguration(currentRuleConfig));
-        result.setKeyGenerators(new 
HashMap<>(currentRuleConfig.getKeyGenerators()));
-        return result;
-    }
-    
-    private KeyGenerateStrategyConfiguration 
getKeyGenerateStrategyConfiguration(final ShardingRuleConfiguration 
currentRuleConfig) {
-        if (null == currentRuleConfig.getDefaultKeyGenerateStrategy()) {
-            return null;
-        }
-        return new 
KeyGenerateStrategyConfiguration(currentRuleConfig.getDefaultKeyGenerateStrategy().getColumn(),
 currentRuleConfig.getDefaultKeyGenerateStrategy().getKeyGeneratorName());
-    }
-    
-    @Override
-    public String getType() {
-        return AlterShardingTableRuleStatement.class.getName();
-    }
-}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessor.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessor.java
deleted file mode 100644
index 15421274157..00000000000
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessor.java
+++ /dev/null
@@ -1,40 +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.infra.distsql.preprocess;
-
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.infra.util.spi.annotation.SingletonSPI;
-import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPI;
-
-/**
- * Rule definition alter preprocessor.
- * 
- * @param <T> type of rule configuration
- */
-@SingletonSPI
-public interface RuleDefinitionAlterPreprocessor<T extends RuleConfiguration> 
extends TypedSPI {
-    
-    /**
-     * Preprocess current rule configuration.
-     *
-     * @param currentRuleConfig current rule configuration to be updated
-     * @param toBeAlteredRuleConfig to be altered rule configuration
-     * @return altered current rule configuration
-     */
-    T preprocess(T currentRuleConfig, T toBeAlteredRuleConfig);
-}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactory.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactory.java
deleted file mode 100644
index 19c952ac3bb..00000000000
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactory.java
+++ /dev/null
@@ -1,48 +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.infra.distsql.preprocess;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-
-import java.util.Optional;
-
-/**
- * Rule definition alter preprocessor factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class RuleDefinitionAlterPreprocessorFactory {
-    
-    static {
-        
ShardingSphereServiceLoader.register(RuleDefinitionAlterPreprocessor.class);
-    }
-    
-    /**
-     * Find instance of rule definition alter preprocessor.
-     *
-     * @param sqlStatement SQL statement
-     * @return found instance
-     */
-    @SuppressWarnings("rawtypes")
-    public static Optional<RuleDefinitionAlterPreprocessor> findInstance(final 
SQLStatement sqlStatement) {
-        return 
TypedSPIRegistry.findRegisteredService(RuleDefinitionAlterPreprocessor.class, 
sqlStatement.getClass().getCanonicalName());
-    }
-}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactoryTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactoryTest.java
deleted file mode 100644
index 4533ba5dccd..00000000000
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactoryTest.java
+++ /dev/null
@@ -1,39 +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.infra.distsql.preprocess;
-
-import 
org.apache.shardingsphere.infra.fixture.FixtureRuleDefinitionAlterPreprocessor;
-import org.apache.shardingsphere.infra.fixture.FixtureRuleStatement;
-import org.junit.Test;
-
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-public final class RuleDefinitionAlterPreprocessorFactoryTest {
-    
-    @SuppressWarnings("rawtypes")
-    @Test
-    public void assertFindInstance() {
-        Optional<RuleDefinitionAlterPreprocessor> actual = 
RuleDefinitionAlterPreprocessorFactory.findInstance(new FixtureRuleStatement());
-        assertTrue(actual.isPresent());
-        assertThat(actual.get(), 
instanceOf(FixtureRuleDefinitionAlterPreprocessor.class));
-    }
-}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionAlterPreprocessor.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionAlterPreprocessor.java
deleted file mode 100644
index 05f18ec3c19..00000000000
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionAlterPreprocessor.java
+++ /dev/null
@@ -1,33 +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.infra.fixture;
-
-import 
org.apache.shardingsphere.infra.distsql.preprocess.RuleDefinitionAlterPreprocessor;
-
-public final class FixtureRuleDefinitionAlterPreprocessor implements 
RuleDefinitionAlterPreprocessor<FixtureRuleConfiguration> {
-    
-    @Override
-    public FixtureRuleConfiguration preprocess(final FixtureRuleConfiguration 
currentRuleConfig, final FixtureRuleConfiguration toBeAlteredRuleConfig) {
-        return null;
-    }
-    
-    @Override
-    public String getType() {
-        return FixtureRuleStatement.class.getName();
-    }
-}
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
index bc7d7bfb54a..84a73cc88d3 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
@@ -25,7 +25,6 @@ import 
org.apache.shardingsphere.infra.instance.metadata.jdbc.JDBCInstanceMetaDa
 import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
 import org.apache.shardingsphere.mode.lock.LockPersistService;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.cache.subscriber.ScalingRegistrySubscriber;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.subscriber.SchemaMetaDataRegistrySubscriber;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service.ComputeNodeStatusService;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.subscriber.ComputeNodeStatusSubscriber;
@@ -83,7 +82,6 @@ public final class RegistryCenter {
         new SchemaMetaDataRegistrySubscriber(repository, eventBusContext);
         new ComputeNodeStatusSubscriber(this, repository);
         new StorageNodeStatusSubscriber(repository, eventBusContext);
-        new ScalingRegistrySubscriber(repository, eventBusContext);
         new ProcessRegistrySubscriber(repository, eventBusContext);
     }
     
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/event/StartScalingEvent.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/event/StartScalingEvent.java
deleted file mode 100644
index 191fc771d30..00000000000
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/event/StartScalingEvent.java
+++ /dev/null
@@ -1,45 +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.mode.manager.cluster.coordinator.registry.cache.event;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.ToString;
-
-/**
- * Start scaling event.
- */
-@RequiredArgsConstructor
-@Getter
-@ToString(exclude = {"sourceDataSource", "sourceRule", "targetDataSource", 
"targetRule"})
-public final class StartScalingEvent {
-    
-    private final String databaseName;
-    
-    private final String sourceDataSource;
-    
-    private final String sourceRule;
-    
-    private final String targetDataSource;
-    
-    private final String targetRule;
-    
-    private final int activeVersion;
-    
-    private final int newVersion;
-}
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriber.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriber.java
deleted file mode 100644
index b392f4d8a26..00000000000
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriber.java
+++ /dev/null
@@ -1,89 +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.mode.manager.cluster.coordinator.registry.cache.subscriber;
-
-import com.google.common.eventbus.Subscribe;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.cache.event.StartScalingEvent;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.ScalingTaskFinishedEvent;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.version.MetadataVersionPreparedEvent;
-import 
org.apache.shardingsphere.mode.metadata.persist.node.DatabaseMetaDataNode;
-import 
org.apache.shardingsphere.mode.metadata.persist.service.MetaDataVersionPersistService;
-import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
-
-import java.util.Optional;
-
-/**
- * Scaling registry subscriber.
- */
-@SuppressWarnings("UnstableApiUsage")
-@Slf4j
-// TODO move to scaling module
-public final class ScalingRegistrySubscriber {
-    
-    private final ClusterPersistRepository repository;
-    
-    private final MetaDataVersionPersistService metaDataVersionPersistService;
-    
-    private final EventBusContext eventBusContext;
-    
-    public ScalingRegistrySubscriber(final ClusterPersistRepository 
repository, final EventBusContext eventBusContext) {
-        this.repository = repository;
-        this.eventBusContext = eventBusContext;
-        metaDataVersionPersistService = new 
MetaDataVersionPersistService(repository);
-        eventBusContext.register(this);
-    }
-    
-    /**
-     * Start scaling after new schema version prepared.
-     *
-     * @param event Schema version prepared event.
-     */
-    @Subscribe
-    public void startScaling(final MetadataVersionPreparedEvent event) {
-        String databaseName = event.getDatabaseName();
-        String activeVersion = 
metaDataVersionPersistService.getActiveVersion(databaseName).get();
-        String sourceDataSource = 
repository.get(DatabaseMetaDataNode.getMetaDataDataSourcePath(databaseName, 
activeVersion));
-        String targetDataSource = 
repository.get(DatabaseMetaDataNode.getMetaDataDataSourcePath(databaseName, 
event.getVersion()));
-        String sourceRule = 
repository.get(DatabaseMetaDataNode.getRulePath(databaseName, activeVersion));
-        String targetRule = 
repository.get(DatabaseMetaDataNode.getRulePath(databaseName, 
event.getVersion()));
-        log.info("start scaling job, locked the schema name, event={}", event);
-        StartScalingEvent startScalingEvent = new 
StartScalingEvent(databaseName, sourceDataSource, sourceRule, targetDataSource, 
targetRule,
-                Integer.parseInt(activeVersion), 
Integer.parseInt(event.getVersion()));
-        eventBusContext.post(startScalingEvent);
-    }
-    
-    /**
-     * Scaling task finished.
-     *
-     * @param event scaling task finished event
-     */
-    @Subscribe
-    public void scalingTaskFinished(final ScalingTaskFinishedEvent event) {
-        log.info("scalingTaskFinished, event={}", event);
-        int targetActiveVersion = event.getTargetActiveVersion();
-        Optional<String> activeVersion = 
metaDataVersionPersistService.getActiveVersion(event.getTargetSchemaName());
-        if (activeVersion.isPresent() && targetActiveVersion == 
Integer.parseInt(activeVersion.get())) {
-            
metaDataVersionPersistService.persistActiveVersion(event.getTargetSchemaName(), 
event.getTargetNewVersion() + "");
-            
metaDataVersionPersistService.deleteVersion(event.getTargetSchemaName(), 
targetActiveVersion + "");
-        } else {
-            log.error("targetActiveVersion does not match current 
activeVersion, targetActiveVersion={}, activeVersion={}", targetActiveVersion, 
activeVersion.orElse(null));
-        }
-    }
-}
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/event/rule/ScalingTaskFinishedEvent.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/event/rule/ScalingTaskFinishedEvent.java
deleted file mode 100644
index c3d54439548..00000000000
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/event/rule/ScalingTaskFinishedEvent.java
+++ /dev/null
@@ -1,39 +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.mode.manager.cluster.coordinator.registry.config.event.rule;
-
-import lombok.Getter;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
-import lombok.ToString;
-
-/**
- * Scaling task finished event.
- */
-@RequiredArgsConstructor
-@Getter
-@ToString
-public final class ScalingTaskFinishedEvent {
-    
-    @NonNull
-    private final String targetSchemaName;
-    
-    private final int targetActiveVersion;
-    
-    private final int targetNewVersion;
-}
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/event/version/MetadataVersionPreparedEvent.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/event/version/MetadataVersionPreparedEvent.java
deleted file mode 100644
index 7fe82ba8f43..00000000000
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/event/version/MetadataVersionPreparedEvent.java
+++ /dev/null
@@ -1,35 +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.mode.manager.cluster.coordinator.registry.config.event.version;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.ToString;
-
-/**
- * Metadata version prepared event.
- */
-@RequiredArgsConstructor
-@Getter
-@ToString
-public final class MetadataVersionPreparedEvent {
-    
-    private final String version;
-    
-    private final String databaseName;
-}
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriberTest.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriberTest.java
deleted file mode 100644
index f6995a951ea..00000000000
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/cache/subscriber/ScalingRegistrySubscriberTest.java
+++ /dev/null
@@ -1,79 +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.mode.manager.cluster.coordinator.registry.cache.subscriber;
-
-import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.cache.event.StartScalingEvent;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.ScalingTaskFinishedEvent;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.version.MetadataVersionPreparedEvent;
-import 
org.apache.shardingsphere.mode.metadata.persist.service.MetaDataVersionPersistService;
-import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentMatchers;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.lang.reflect.Field;
-import java.util.Optional;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class ScalingRegistrySubscriberTest {
-    
-    @Mock
-    private ClusterPersistRepository repository;
-    
-    @Mock
-    private MetaDataVersionPersistService metaDataVersionPersistService;
-    
-    @Mock
-    private EventBusContext eventBusContext;
-    
-    private ScalingRegistrySubscriber scalingRegistrySubscriber;
-    
-    @Before
-    public void setUp() throws ReflectiveOperationException {
-        scalingRegistrySubscriber = new ScalingRegistrySubscriber(repository, 
eventBusContext);
-        Field persistServiceField = 
ScalingRegistrySubscriber.class.getDeclaredField("metaDataVersionPersistService");
-        persistServiceField.setAccessible(true);
-        persistServiceField.set(scalingRegistrySubscriber, 
metaDataVersionPersistService);
-    }
-    
-    @Test
-    public void assertStartScaling() {
-        verify(eventBusContext).register(scalingRegistrySubscriber);
-        
when(metaDataVersionPersistService.getActiveVersion("ds_0")).thenReturn(Optional.of("1"));
-        when(repository.get(any())).thenReturn("");
-        scalingRegistrySubscriber.startScaling(new 
MetadataVersionPreparedEvent("2", "ds_0"));
-        StartScalingEvent startScalingEvent = new StartScalingEvent("ds_0", 
"", "", "", "", 1, 2);
-        
verify(eventBusContext).post(ArgumentMatchers.refEq(startScalingEvent));
-    }
-    
-    @Test
-    public void assertScalingTaskFinished() {
-        
when(metaDataVersionPersistService.getActiveVersion("ds_0")).thenReturn(Optional.of("1"));
-        scalingRegistrySubscriber.scalingTaskFinished(new 
ScalingTaskFinishedEvent("ds_0", 1, 2));
-        verify(metaDataVersionPersistService).persistActiveVersion("ds_0", 
"2");
-        verify(metaDataVersionPersistService).deleteVersion("ds_0", "1");
-    }
-}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
index da85cb3f2fb..520f916c5c0 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
@@ -21,17 +21,13 @@ import lombok.extern.slf4j.Slf4j;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.RuleDefinitionStatement;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
-import 
org.apache.shardingsphere.infra.distsql.preprocess.RuleDefinitionAlterPreprocessor;
-import 
org.apache.shardingsphere.infra.distsql.preprocess.RuleDefinitionAlterPreprocessorFactory;
 import 
org.apache.shardingsphere.infra.distsql.update.RuleDefinitionAlterUpdater;
 import 
org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdater;
 import 
org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
 import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater;
 import 
org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdaterFactory;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.version.MetadataVersionPreparedEvent;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.backend.handler.DatabaseRequiredBackendHandler;
 import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -74,11 +70,6 @@ public final class RuleDefinitionBackendHandler<T extends 
RuleDefinitionStatemen
         ShardingSphereDatabase database = 
ProxyContext.getInstance().getDatabase(databaseName);
         RuleConfiguration currentRuleConfig = 
findCurrentRuleConfiguration(database, ruleConfigClass).orElse(null);
         ruleDefinitionUpdater.checkSQLStatement(database, sqlStatement, 
currentRuleConfig);
-        Optional<RuleDefinitionAlterPreprocessor> preprocessor = 
RuleDefinitionAlterPreprocessorFactory.findInstance(sqlStatement);
-        if (preprocessor.isPresent()) {
-            prepareScaling(database, sqlStatement, 
(RuleDefinitionAlterUpdater) ruleDefinitionUpdater, currentRuleConfig, 
preprocessor.get());
-            return new UpdateResponseHeader(sqlStatement);
-        }
         if (getRefreshStatus(sqlStatement, currentRuleConfig, 
ruleDefinitionUpdater)) {
             Collection<RuleConfiguration> alteredConfigs = 
processSQLStatement(database, sqlStatement, ruleDefinitionUpdater, 
currentRuleConfig);
             persistRuleConfigurationChange(databaseName, alteredConfigs);
@@ -143,38 +134,11 @@ public final class RuleDefinitionBackendHandler<T extends 
RuleDefinitionStatemen
         }
     }
     
-    private void prepareScaling(final ShardingSphereDatabase database, final T 
sqlStatement, final RuleDefinitionAlterUpdater<?, ?> updater, final 
RuleConfiguration currentRuleConfig,
-                                final RuleDefinitionAlterPreprocessor<?> 
preprocessor) {
-        MetaDataPersistService persistService = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getPersistService();
-        Optional<String> newVersion = 
persistService.getMetaDataVersionPersistService().createNewVersion(database.getName());
-        if (!newVersion.isPresent()) {
-            throw new RuntimeException(String.format("Unable to get a new 
version for database: %s", database.getName()));
-        }
-        persistRuleConfigurationChange(persistService, newVersion.get(), 
database, currentRuleConfig, getAlteredRuleConfig(sqlStatement, updater, 
currentRuleConfig, preprocessor));
-    }
-    
-    private void persistRuleConfigurationChange(final MetaDataPersistService 
persistService, final String version, final ShardingSphereDatabase database,
-                                                final RuleConfiguration 
currentRuleConfig, final RuleConfiguration alteredRuleConfig) {
-        Collection<RuleConfiguration> configs = new 
LinkedList<>(database.getRuleMetaData().getConfigurations());
-        configs.remove(currentRuleConfig);
-        configs.add(alteredRuleConfig);
-        
persistService.getDatabaseRulePersistService().persist(database.getName(), 
version, configs);
-        
ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext().post(new
 MetadataVersionPreparedEvent(version, database.getName()));
-    }
-    
     private void persistRuleConfigurationChange(final String databaseName, 
final Collection<RuleConfiguration> alteredConfigs) {
         MetaDataContexts metaDataContexts = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts();
         
metaDataContexts.getPersistService().getDatabaseRulePersistService().persist(metaDataContexts.getMetaData().getActualDatabaseName(databaseName),
 alteredConfigs);
     }
     
-    private RuleConfiguration getAlteredRuleConfig(final T sqlStatement, final 
RuleDefinitionAlterUpdater updater,
-                                                   final RuleConfiguration 
currentRuleConfig, final RuleDefinitionAlterPreprocessor preprocessor) {
-        RuleConfiguration toBeAlteredRuleConfig = 
updater.buildToBeAlteredRuleConfiguration(sqlStatement);
-        RuleConfiguration result = preprocessor.preprocess(currentRuleConfig, 
toBeAlteredRuleConfig);
-        updater.updateCurrentRuleConfiguration(result, toBeAlteredRuleConfig);
-        return result;
-    }
-    
     private boolean getRefreshStatus(final SQLStatement sqlStatement, final 
RuleConfiguration currentRuleConfig, final RuleDefinitionUpdater<?, ?> updater) 
{
         if (updater instanceof RuleDefinitionDropUpdater) {
             return ((RuleDefinitionDropUpdater) 
updater).hasAnyOneToBeDropped(sqlStatement, currentRuleConfig);
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index a3a59bd4082..ae20ccb259f 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -993,7 +993,7 @@ public final class SQLParserTestCases {
     private final List<ShowShardingTableRulesStatementTestCase> 
showShardingTableRuleTestCases = new LinkedList<>();
     
     @XmlElement(name = "show-migration-source-resources")
-    private final List<ShowMigrationSourceResourcesStatementTestCase> 
showScalingCheckAlgorithmsTestCases = new LinkedList<>();
+    private final List<ShowMigrationSourceResourcesStatementTestCase> 
showMigrationResourcesStatementTestCases = new LinkedList<>();
     
     @XmlElement(name = "show-migration-list")
     private final List<ShowMigrationListStatementTestCase> 
showMigrationListTestCases = new LinkedList<>();

Reply via email to