Skip to content

Commit

Permalink
Change NewYamlXxxxRuleConfigurationSwapper to YamlXxxxDataNodeRuleCon…
Browse files Browse the repository at this point in the history
…figurationSwapper (#30455)
  • Loading branch information
zhaojinchao95 authored Mar 12, 2024
1 parent 12f60c9 commit 38a9d3c
Show file tree
Hide file tree
Showing 63 changed files with 266 additions and 285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.shardingsphere.mode.path.RuleNodePath;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlDataNodeRuleConfigurationSwapper;

import java.util.Collection;
import java.util.Collections;
Expand All @@ -33,10 +33,9 @@
import java.util.stream.Collectors;

/**
* TODO Rename to YamlBroadcastRuleConfigurationSwapper when metadata structure adjustment completed.
* New YAML broadcast rule configuration swapper.
* YAML broadcast data node rule configuration swapper.
*/
public final class NewYamlBroadcastRuleConfigurationSwapper implements NewYamlRuleConfigurationSwapper<BroadcastRuleConfiguration> {
public final class YamlBroadcastDataNodeRuleConfigurationSwapper implements YamlDataNodeRuleConfigurationSwapper<BroadcastRuleConfiguration> {

private final RuleNodePath broadcastRuleNodePath = new BroadcastRuleNodePathProvider().getRuleNodePath();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#

org.apache.shardingsphere.broadcast.yaml.swapper.YamlBroadcastDataNodeRuleConfigurationSwapper
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

class NewYamlBroadcastRuleConfigurationSwapperTest {

private final NewYamlBroadcastRuleConfigurationSwapper swapper = new NewYamlBroadcastRuleConfigurationSwapper();
private final YamlBroadcastDataNodeRuleConfigurationSwapper swapper = new YamlBroadcastDataNodeRuleConfigurationSwapper();

@Test
void assertSwapEmptyConfigToDataNodes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlDataNodeRuleConfigurationSwapper;

import java.util.Collection;
import java.util.LinkedHashMap;
Expand All @@ -41,10 +41,9 @@
import java.util.stream.Collectors;

/**
* TODO Rename to YamlEncryptRuleConfigurationSwapper when metadata structure adjustment completed.
* New YAML encrypt rule configuration swapper.
* YAML encrypt data node rule configuration swapper.
*/
public final class NewYamlEncryptRuleConfigurationSwapper implements NewYamlRuleConfigurationSwapper<EncryptRuleConfiguration> {
public final class YamlEncryptDataNodeRuleConfigurationSwapper implements YamlDataNodeRuleConfigurationSwapper<EncryptRuleConfiguration> {

private final YamlEncryptTableRuleConfigurationSwapper tableSwapper = new YamlEncryptTableRuleConfigurationSwapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.broadcast.yaml.swapper.NewYamlBroadcastRuleConfigurationSwapper
org.apache.shardingsphere.encrypt.yaml.swapper.YamlEncryptDataNodeRuleConfigurationSwapper
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

class NewYamlEncryptRuleConfigurationSwapperTest {

private final NewYamlEncryptRuleConfigurationSwapper swapper = new NewYamlEncryptRuleConfigurationSwapper();
private final YamlEncryptDataNodeRuleConfigurationSwapper swapper = new YamlEncryptDataNodeRuleConfigurationSwapper();

@Test
void assertSwapEmptyConfigToDataNodes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlDataNodeRuleConfigurationSwapper;
import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
import org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
import org.apache.shardingsphere.mask.constant.MaskOrder;
Expand All @@ -41,10 +41,9 @@
import java.util.stream.Collectors;

/**
* TODO Rename to YamlMaskRuleConfigurationSwapper when metadata structure adjustment completed.
* New YAML mask rule configuration swapper.
* YAML mask data node rule configuration swapper.
*/
public final class NewYamlMaskRuleConfigurationSwapper implements NewYamlRuleConfigurationSwapper<MaskRuleConfiguration> {
public final class YamlMaskDataNodeRuleConfigurationSwapper implements YamlDataNodeRuleConfigurationSwapper<MaskRuleConfiguration> {

private final YamlMaskTableRuleConfigurationSwapper tableSwapper = new YamlMaskTableRuleConfigurationSwapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.mask.yaml.swapper.NewYamlMaskRuleConfigurationSwapper
org.apache.shardingsphere.mask.yaml.swapper.YamlMaskDataNodeRuleConfigurationSwapper
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

class NewYamlMaskRuleConfigurationSwapperTest {

private final NewYamlMaskRuleConfigurationSwapper swapper = new NewYamlMaskRuleConfigurationSwapper();
private final YamlMaskDataNodeRuleConfigurationSwapper swapper = new YamlMaskDataNodeRuleConfigurationSwapper();

@Test
void assertSwapEmptyConfigToDataNodes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlDataNodeRuleConfigurationSwapper;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.api.transaction.TransactionalReadQueryStrategy;
Expand All @@ -42,10 +42,9 @@
import java.util.stream.Collectors;

/**
* TODO Rename YamlReadwriteSplittingRuleConfigurationSwapper when metadata structure adjustment completed. #25485
* YAML readwrite-splitting rule configuration swapper.
* YAML readwrite-splitting data node rule configuration swapper.
*/
public final class NewYamlReadwriteSplittingRuleConfigurationSwapper implements NewYamlRuleConfigurationSwapper<ReadwriteSplittingRuleConfiguration> {
public final class YamlReadwriteSplittingDataNodeRuleConfigurationSwapper implements YamlDataNodeRuleConfigurationSwapper<ReadwriteSplittingRuleConfiguration> {

private final YamlAlgorithmConfigurationSwapper algorithmSwapper = new YamlAlgorithmConfigurationSwapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.readwritesplitting.yaml.swapper.NewYamlReadwriteSplittingRuleConfigurationSwapper
org.apache.shardingsphere.readwritesplitting.yaml.swapper.YamlReadwriteSplittingDataNodeRuleConfigurationSwapper
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

class NewYamlReadwriteSplittingRuleConfigurationSwapperTest {

private final NewYamlReadwriteSplittingRuleConfigurationSwapper swapper = new NewYamlReadwriteSplittingRuleConfigurationSwapper();
private final YamlReadwriteSplittingDataNodeRuleConfigurationSwapper swapper = new YamlReadwriteSplittingDataNodeRuleConfigurationSwapper();

@Test
void assertSwapToDataNodesLoadBalancersEmpty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlDataNodeRuleConfigurationSwapper;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
Expand All @@ -42,10 +42,9 @@
import java.util.stream.Collectors;

/**
* TODO Rename YamlShadowRuleConfigurationSwapper when metadata structure adjustment completed.
* New YAML shadow rule configuration swapper.
* YAML shadow data node rule configuration swapper.
*/
public final class NewYamlShadowRuleConfigurationSwapper implements NewYamlRuleConfigurationSwapper<ShadowRuleConfiguration> {
public final class YamlShadowDataNodeRuleConfigurationSwapper implements YamlDataNodeRuleConfigurationSwapper<ShadowRuleConfiguration> {

private final YamlShadowTableConfigurationSwapper tableSwapper = new YamlShadowTableConfigurationSwapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.sharding.yaml.swapper.NewYamlShardingRuleConfigurationSwapper
org.apache.shardingsphere.shadow.yaml.swapper.YamlShadowDataNodeRuleConfigurationSwapper
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

class NewYamlShadowRuleConfigurationSwapperTest {

private final NewYamlShadowRuleConfigurationSwapper swapper = new NewYamlShadowRuleConfigurationSwapper();
private final YamlShadowDataNodeRuleConfigurationSwapper swapper = new YamlShadowDataNodeRuleConfigurationSwapper();

@Test
void assertSwapEmptyConfigToDataNodes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlDataNodeRuleConfigurationSwapper;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
Expand Down Expand Up @@ -52,10 +52,9 @@
import java.util.stream.Collectors;

/**
* TODO Rename to YamlShardingRuleConfigurationSwapper when metadata structure adjustment completed. #25485
* New YAML sharding rule configuration swapper.
* YAML sharding data node rule configuration swapper.
*/
public final class NewYamlShardingRuleConfigurationSwapper implements NewYamlRuleConfigurationSwapper<ShardingRuleConfiguration> {
public final class YamlShardingDataNodeRuleConfigurationSwapper implements YamlDataNodeRuleConfigurationSwapper<ShardingRuleConfiguration> {

private final YamlShardingTableRuleConfigurationSwapper tableSwapper = new YamlShardingTableRuleConfigurationSwapper();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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.
#

org.apache.shardingsphere.sharding.yaml.swapper.YamlShardingDataNodeRuleConfigurationSwapper
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

class NewYamlShardingRuleConfigurationSwapperTest {

private final NewYamlShardingRuleConfigurationSwapper swapper = new NewYamlShardingRuleConfigurationSwapper();
private final YamlShardingDataNodeRuleConfigurationSwapper swapper = new YamlShardingDataNodeRuleConfigurationSwapper();

@Test
void assertSwapEmptyConfigToDataNodes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,6 @@ public Optional<ComputeNodeInstance> getComputeNodeInstanceById(final String ins
* @return true if is cluster, else false
*/
public boolean isCluster() {
return "Cluster".equals(modeConfiguration.getType()) || "Compatible_Cluster".equals(modeConfiguration.getType());
return "Cluster".equals(modeConfiguration.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPI;
import org.apache.shardingsphere.infra.util.yaml.swapper.NewYamlConfigurationSwapper;
import org.apache.shardingsphere.infra.util.yaml.swapper.YamlDataNodeConfigurationSwapper;

/**
* TODO Rename YamlRuleConfigurationSwapper when metadata structure adjustment completed. #25485
* YAML rule configuration swapper.
* YAML data node rule global configuration swapper.
*
* @param <T> type of rule configuration
*/
@SingletonSPI
public interface NewYamlRuleConfigurationSwapper<T extends RuleConfiguration> extends NewYamlConfigurationSwapper<T>, OrderedSPI<T> {
public interface YamlDataNodeGlobalRuleConfigurationSwapper<T extends RuleConfiguration> extends YamlDataNodeConfigurationSwapper<T>, OrderedSPI<T> {

/**
* Get YAML rule tag name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
import java.util.Optional;

/**
* TODO Rename YamlGlobalRuleConfigurationSwapperEngine when metadata structure adjustment completed. #25485
* YAML global rule configuration swapper engine.
* YAML data node global rule configuration swapper engine.
*/
public final class NewYamlGlobalRuleConfigurationSwapperEngine {
public final class YamlDataNodeGlobalRuleConfigurationSwapperEngine {

/**
* Swap to YAML global rule configurations.
Expand All @@ -39,8 +38,8 @@ public final class NewYamlGlobalRuleConfigurationSwapperEngine {
* @return YAML global rule configurations
*/
@SuppressWarnings("rawtypes")
public Map<RuleConfiguration, NewYamlGlobalRuleConfigurationSwapper> swapToYamlRuleConfigurations(final Collection<RuleConfiguration> ruleConfigs) {
return OrderedSPILoader.getServices(NewYamlGlobalRuleConfigurationSwapper.class, ruleConfigs);
public Map<RuleConfiguration, YamlDataNodeGlobalRuleConfigurationSwapper> swapToYamlRuleConfigurations(final Collection<RuleConfiguration> ruleConfigs) {
return OrderedSPILoader.getServices(YamlDataNodeGlobalRuleConfigurationSwapper.class, ruleConfigs);
}

/**
Expand All @@ -52,7 +51,7 @@ public Map<RuleConfiguration, NewYamlGlobalRuleConfigurationSwapper> swapToYamlR
@SuppressWarnings({"unchecked", "rawtypes"})
public Collection<RuleConfiguration> swapToRuleConfigurations(final Collection<YamlDataNode> dataNodes) {
Collection<RuleConfiguration> result = new LinkedList<>();
for (NewYamlGlobalRuleConfigurationSwapper each : OrderedSPILoader.getServices(NewYamlGlobalRuleConfigurationSwapper.class)) {
for (YamlDataNodeGlobalRuleConfigurationSwapper each : OrderedSPILoader.getServices(YamlDataNodeGlobalRuleConfigurationSwapper.class)) {
each.swapToObject(dataNodes).ifPresent(optional -> result.add((RuleConfiguration) optional));
}
return result;
Expand All @@ -67,7 +66,7 @@ public Collection<RuleConfiguration> swapToRuleConfigurations(final Collection<Y
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public Optional<RuleConfiguration> swapSingleRuleToRuleConfiguration(final String ruleName, final Collection<YamlDataNode> dataNodes) {
for (NewYamlGlobalRuleConfigurationSwapper each : OrderedSPILoader.getServices(NewYamlGlobalRuleConfigurationSwapper.class)) {
for (YamlDataNodeGlobalRuleConfigurationSwapper each : OrderedSPILoader.getServices(YamlDataNodeGlobalRuleConfigurationSwapper.class)) {
if (ruleName.equals(each.getRuleTagName().toLowerCase())) {
return each.swapToObject(dataNodes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPI;
import org.apache.shardingsphere.infra.util.yaml.swapper.NewYamlConfigurationSwapper;
import org.apache.shardingsphere.infra.util.yaml.swapper.YamlDataNodeConfigurationSwapper;

/**
* TODO Rename YamGlobalRuleConfigurationSwapper when metadata structure adjustment completed. #25485
* YAML rule global configuration swapper.
* YAML data node rule configuration swapper.
*
* @param <T> type of rule configuration
*/
@SingletonSPI
public interface NewYamlGlobalRuleConfigurationSwapper<T extends RuleConfiguration> extends NewYamlConfigurationSwapper<T>, OrderedSPI<T> {
public interface YamlDataNodeRuleConfigurationSwapper<T extends RuleConfiguration> extends YamlDataNodeConfigurationSwapper<T>, OrderedSPI<T> {

/**
* Get YAML rule tag name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
import java.util.Map;

/**
* TODO Rename YamlRuleConfigurationSwapper when metadata structure adjustment completed. #25485
* YAML rule configuration swapper engine.
* YAML data node rule configuration swapper engine.
*/
public final class NewYamlRuleConfigurationSwapperEngine {
public final class YamlDataNodeRuleConfigurationSwapperEngine {

/**
* Swap to YAML rule configurations.
Expand All @@ -38,8 +37,8 @@ public final class NewYamlRuleConfigurationSwapperEngine {
* @return YAML rule configurations
*/
@SuppressWarnings("rawtypes")
public Map<RuleConfiguration, NewYamlRuleConfigurationSwapper> swapToYamlRuleConfigurations(final Collection<RuleConfiguration> ruleConfigs) {
return OrderedSPILoader.getServices(NewYamlRuleConfigurationSwapper.class, ruleConfigs);
public Map<RuleConfiguration, YamlDataNodeRuleConfigurationSwapper> swapToYamlRuleConfigurations(final Collection<RuleConfiguration> ruleConfigs) {
return OrderedSPILoader.getServices(YamlDataNodeRuleConfigurationSwapper.class, ruleConfigs);
}

/**
Expand All @@ -51,7 +50,7 @@ public Map<RuleConfiguration, NewYamlRuleConfigurationSwapper> swapToYamlRuleCon
@SuppressWarnings({"unchecked", "rawtypes"})
public Collection<RuleConfiguration> swapToRuleConfigurations(final Collection<YamlDataNode> dataNodes) {
Collection<RuleConfiguration> result = new LinkedList<>();
for (NewYamlRuleConfigurationSwapper each : OrderedSPILoader.getServices(NewYamlRuleConfigurationSwapper.class)) {
for (YamlDataNodeRuleConfigurationSwapper each : OrderedSPILoader.getServices(YamlDataNodeRuleConfigurationSwapper.class)) {
each.swapToObject(dataNodes).ifPresent(optional -> result.add((RuleConfiguration) optional));
}
return result;
Expand Down
Loading

0 comments on commit 38a9d3c

Please sign in to comment.