You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by to...@apache.org on 2022/05/08 16:03:22 UTC
[shardingsphere] branch master updated: Remove SPIPropertiesAware (#17455)
This is an automated email from the ASF dual-hosted git repository.
totalo 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 6467ce8738f Remove SPIPropertiesAware (#17455)
6467ce8738f is described below
commit 6467ce8738f310e1852eee4c598fc33d5e08551d
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon May 9 00:03:16 2022 +0800
Remove SPIPropertiesAware (#17455)
---
.../StandardModuloShardingDatabaseAlgorithm.java | 9 ++-
.../StandardModuloShardingTableAlgorithm.java | 10 +++
.../TestQueryAssistedShardingEncryptAlgorithm.java | 9 ++-
...ClassBasedStandardShardingAlgorithmFixture.java | 3 +-
...DatasourceStandardShardingAlgorithmFixture.java | 3 +-
...dOrderItemStandardShardingAlgorithmFixture.java | 3 +-
...BasedOrderStandardShardingAlgorithmFixture.java | 3 +-
...DatasourceStandardShardingAlgorithmFixture.java | 3 +-
...dOrderItemStandardShardingAlgorithmFixture.java | 3 +-
...BasedOrderStandardShardingAlgorithmFixture.java | 3 +-
.../SPIBasedStandardShardingAlgorithmFixture.java | 12 ++-
...DatasourceStandardShardingAlgorithmFixture.java | 10 +++
...dOrderItemStandardShardingAlgorithmFixture.java | 10 +++
...BasedOrderStandardShardingAlgorithmFixture.java | 10 +++
...sedAccountStandardShardingAlgorithmFixture.java | 10 +++
...DatasourceStandardShardingAlgorithmFixture.java | 10 +++
...dOrderItemStandardShardingAlgorithmFixture.java | 10 +++
...BasedOrderStandardShardingAlgorithmFixture.java | 10 +++
.../raw/jdbc/hint/ModuloHintShardingAlgorithm.java | 10 +++
.../proxy/hint/ModuloHintShardingAlgorithm.java | 10 +++
...eDatabaseDiscoveryProviderAlgorithmFixture.java | 10 +++
...LDatabaseDiscoveryProviderAlgorithmFixture.java | 10 +++
...MGRMySQLDatabaseDiscoveryProviderAlgorithm.java | 9 ++-
...licationDatabaseDiscoveryProviderAlgorithm.java | 9 ++-
.../MGRDatabaseDiscoveryProviderAlgorithmTest.java | 12 ++-
...licationDatabaseDiscoveryProviderAlgorithm.java | 9 ++-
.../encrypt/algorithm/AESEncryptAlgorithm.java | 5 +-
.../encrypt/algorithm/MD5EncryptAlgorithm.java | 7 +-
.../encrypt/algorithm/RC4EncryptAlgorithm.java | 3 +-
.../fixture/CoreEncryptAlgorithmFixture.java | 11 +++
.../CoreQueryAssistedEncryptAlgorithmFixture.java | 11 +++
...SchemaMetaDataAwareEncryptAlgorithmFixture.java | 10 +++
.../encrypt/sm/algorithm/SM3EncryptAlgorithm.java | 3 +-
.../encrypt/sm/algorithm/SM4EncryptAlgorithm.java | 3 +-
.../RandomReplicaLoadBalanceAlgorithm.java | 7 +-
.../RoundRobinReplicaLoadBalanceAlgorithm.java | 7 +-
.../WeightReplicaLoadBalanceAlgorithm.java | 9 ++-
.../column/AbstractColumnMatchShadowAlgorithm.java | 5 ++
.../column/ColumnRegexMatchShadowAlgorithm.java | 6 --
.../column/ColumnValueMatchShadowAlgorithm.java | 6 --
.../shadow/hint/SimpleHintShadowAlgorithm.java | 3 +-
.../PropertiesShadowSpringBootStarterTest.java | 8 +-
...=> YamlShadowDefaultSpringBootStarterTest.java} | 4 +-
.../keygen/SnowflakeKeyGenerateAlgorithm.java | 6 +-
.../algorithm/keygen/UUIDKeyGenerateAlgorithm.java | 10 +++
.../classbased/ClassBasedShardingAlgorithm.java | 13 ++-
.../ClassBasedShardingAlgorithmFactory.java | 23 +++---
.../complex/ComplexInlineShardingAlgorithm.java | 13 ++-
.../datetime/AutoIntervalShardingAlgorithm.java | 9 +--
.../datetime/IntervalShardingAlgorithm.java | 17 ++--
.../sharding/hint/HintInlineShardingAlgorithm.java | 7 +-
.../sharding/inline/InlineShardingAlgorithm.java | 7 +-
.../sharding/mod/HashModShardingAlgorithm.java | 5 +-
.../sharding/mod/ModShardingAlgorithm.java | 3 +-
.../range/AbstractRangeShardingAlgorithm.java | 7 +-
.../range/BoundaryBasedRangeShardingAlgorithm.java | 6 --
.../range/VolumeBasedRangeShardingAlgorithm.java | 6 --
...ssBasedComplexKeysShardingAlgorithmFixture.java | 10 +++
.../ClassBasedHintShardingAlgorithmFixture.java | 10 +++
...ClassBasedStandardShardingAlgorithmFixture.java | 10 +++
.../CoreComplexKeysShardingAlgorithmFixture.java | 10 +++
.../fixture/CoreHintShardingAlgorithmFixture.java | 10 +++
.../CoreStandardShardingAlgorithmFixture.java | 10 +++
.../sharding/rule/ShardingRuleTest.java | 45 +++--------
...java => InputJobRateLimitAlgorithmFixture.java} | 16 +++-
...ava => OutputJobRateLimitAlgorithmFixture.java} | 16 +++-
.../keygen/DistSQLKeyGenerateAlgorithmFixture.java | 11 +++
.../BarDistSQLShardingAlgorithmFixture.java | 10 +++
.../FooDistSQLShardingAlgorithmFixture.java | 10 +++
...ta.pipeline.spi.ratelimit.JobRateLimitAlgorithm | 4 +-
.../keygen/CosIdKeyGenerateAlgorithm.java | 7 +-
.../keygen/CosIdSnowflakeKeyGenerateAlgorithm.java | 25 +++---
.../AbstractCosIdIntervalShardingAlgorithm.java | 6 +-
.../interval/CosIdIntervalShardingAlgorithm.java | 6 --
.../CosIdSnowflakeIntervalShardingAlgorithm.java | 6 --
.../sharding/mod/CosIdModShardingAlgorithm.java | 7 +-
.../keygen/NanoIdKeyGenerateAlgorithm.java | 10 +++
.../SpringComplexKeysShardingAlgorithmFixture.java | 10 +++
.../SpringHintShardingAlgorithmFixture.java | 10 +++
.../config/algorithm/ShardingSphereAlgorithm.java | 3 +-
.../ShardingSphereAlgorithmFactoryTest.java | 6 +-
...hm.java => ShardingSphereAlgorithmFixture.java} | 5 +-
....infra.config.algorithm.ShardingSphereAlgorithm | 2 +-
.../encrypt/JDBCEncryptAlgorithmFixture.java | 11 +++
.../JDBCQueryAssistedEncryptAlgorithmFixture.java | 11 +++
.../IncrementKeyGenerateAlgorithmFixture.java | 10 +++
.../ResetIncrementKeyGenerateAlgorithmFixture.java | 9 +++
.../JDBCStandardShardingAlgorithmFixture.java | 10 +++
.../fixture/FixtureClusterPersistRepository.java | 10 +++
.../AbstractAlgorithmProvidedBeanRegistry.java | 92 ++++++++++++----------
.../fixture/FooShardingSphereFixtureAlgorithm.java | 3 +
.../natived/NativeAuthorityProviderAlgorithm.java | 10 +++
...vilegesPermittedAuthorityProviderAlgorithm.java | 11 ++-
...vilegesPermittedAuthorityProviderAlgorithm.java | 10 +++
...RC32MatchDataConsistencyCalculateAlgorithm.java | 10 +++
...DataMatchDataConsistencyCalculateAlgorithm.java | 4 +
.../memory/MemoryPipelineChannelCreator.java | 5 ++
...dleRuleAlteredJobCompletionDetectAlgorithm.java | 3 +-
.../RandomTrafficLoadBalanceAlgorithm.java | 10 +++
.../RoundRobinTrafficLoadBalanceAlgorithm.java | 10 +++
.../traffic/hint/SQLHintTrafficAlgorithm.java | 11 +++
.../traffic/segment/SQLMatchTrafficAlgorithm.java | 3 +-
.../traffic/segment/SQLRegexTrafficAlgorithm.java | 3 +-
.../transaction/FirstSQLTrafficAlgorithm.java | 11 +++
.../traffic/transaction/JDBCTrafficAlgorithm.java | 11 +++
.../traffic/transaction/ProxyTrafficAlgorithm.java | 11 +++
.../mode/persist/PersistRepository.java | 4 +-
.../fixture/ClusterPersistRepositoryFixture.java | 10 +++
...ProcessListClusterPersistRepositoryFixture.java | 12 ++-
.../repository/cluster/etcd/EtcdRepository.java | 9 ++-
.../zookeeper/CuratorZookeeperRepository.java | 7 +-
.../zookeeper/CuratorZookeeperRepositoryTest.java | 8 +-
.../StandalonePersistRepositoryFixture.java | 12 ++-
.../repository/standalone/file/FileRepository.java | 7 +-
.../standalone/file/FileRepositoryTest.java | 2 +-
.../repository/standalone/h2/H2Repository.java | 6 +-
.../repository/standalone/h2/H2RepositoryTest.java | 2 +-
.../fixture/DistSQLTrafficAlgorithmFixture.java | 11 +++
.../DistSQLTrafficLoadBalanceAlgorithmFixture.java | 10 +++
.../fixture/FixtureClusterPersistRepository.java | 10 +++
.../spi/aware/SPIPropertiesAware.java | 43 ----------
.../spi/lifecycle/SPIPostProcessor.java | 10 ++-
.../spi/type/typed/TypedSPIRegistry.java | 4 -
.../type/typed/fixture/TypedSPIFixtureImpl.java | 9 ++-
.../fixture/TestClusterPersistRepository.java | 10 +++
.../keygen/DriverKeyGenerateAlgorithmFixture.java | 10 +++
.../DriverComplexKeysShardingAlgorithmFixture.java | 10 +++
.../DriverStandardShardingAlgorithmFixture.java | 10 +++
.../fixture/ITKeyGenerateAlgorithmFixture.java | 11 +++
.../ITStandardShardingAlgorithmFixture.java | 10 +++
.../DataConsistencyCalculateAlgorithmFixture.java | 10 +++
...va => JobCompletionDetectAlgorithmFixture.java} | 13 ++-
...ipeline.spi.detect.JobCompletionDetectAlgorithm | 2 +-
.../RewriteNormalEncryptAlgorithmFixture.java | 11 +++
...ewriteQueryAssistedEncryptAlgorithmFixture.java | 11 +++
...SchemaMetaDataAwareEncryptAlgorithmFixture.java | 13 ++-
.../keygen/RewriteKeyGenerateAlgorithmFixture.java | 11 +++
137 files changed, 962 insertions(+), 350 deletions(-)
diff --git a/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/algorithm/StandardModuloShardingDatabaseAlgorithm.java b/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/algorithm/StandardModuloShardingDatabaseAlgorithm.java
index 687c24c0ba1..fa8008729fc 100644
--- a/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/algorithm/StandardModuloShardingDatabaseAlgorithm.java
+++ b/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/algorithm/StandardModuloShardingDatabaseAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.example.algorithm;
import com.google.common.collect.Range;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -29,12 +28,16 @@ import java.util.LinkedHashSet;
import java.util.Properties;
import java.util.Set;
+@Getter
public final class StandardModuloShardingDatabaseAlgorithm implements StandardShardingAlgorithm<Integer> {
- @Getter
- @Setter
private Properties props;
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> databaseNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : databaseNames) {
diff --git a/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/algorithm/StandardModuloShardingTableAlgorithm.java b/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/algorithm/StandardModuloShardingTableAlgorithm.java
index ee99a459bd1..7f44863faad 100644
--- a/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/algorithm/StandardModuloShardingTableAlgorithm.java
+++ b/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/algorithm/StandardModuloShardingTableAlgorithm.java
@@ -18,16 +18,26 @@
package org.apache.shardingsphere.example.algorithm;
import com.google.common.collect.Range;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
import java.util.LinkedHashSet;
+import java.util.Properties;
import java.util.Set;
+@Getter
public final class StandardModuloShardingTableAlgorithm implements StandardShardingAlgorithm<Long> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> tableNames, final PreciseShardingValue<Long> shardingValue) {
for (String each : tableNames) {
diff --git a/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java b/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java
index b172401f6ce..6a71c2ccc03 100644
--- a/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java
+++ b/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java
@@ -18,18 +18,21 @@
package org.apache.shardingsphere.example.fixture;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.encrypt.spi.QueryAssistedEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
import java.util.Properties;
+@Getter
public final class TestQueryAssistedShardingEncryptAlgorithm implements QueryAssistedEncryptAlgorithm<Object, String> {
- @Getter
- @Setter
private Properties props;
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return "encryptValue";
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/raw/jdbc/fixture/ClassBasedStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-exa [...]
index bcb98b1cd1f..2a06c56e378 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/raw/jdbc/fixture/ClassBasedStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/raw/jdbc/fixture/ClassBasedStandardShardingAlgorithmFixture.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.example.extension.classbased.sharding.raw.jdbc
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -33,13 +32,13 @@ public final class ClassBasedStandardShardingAlgorithmFixture implements Standar
private static final String SHARDING_COUNT = "sharding-count";
@Getter
- @Setter
private Properties props;
private Integer shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT), "%s can not be null.", SHARDING_COUNT);
shardingCount = Ints.tryParse(props.getProperty(SHARDING_COUNT));
Preconditions.checkArgument(null != shardingCount, "%s is not valid.", SHARDING_COUNT);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedDatasourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/cl [...]
index 40c4f63622e..8793341beb7 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedDatasourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedDatasourceStandardShardingAlgorithmFixture.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.example.extension.classbased.sharding.spring.b
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -33,13 +32,13 @@ public final class ClassBasedDatasourceStandardShardingAlgorithmFixture implemen
private static final String SHARDING_COUNT = "sharding-count";
@Getter
- @Setter
private Properties props;
private Integer shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT), "%s can not be null.", SHARDING_COUNT);
shardingCount = Ints.tryParse(props.getProperty(SHARDING_COUNT));
Preconditions.checkArgument(null != shardingCount, "%s is not valid.", SHARDING_COUNT);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedOrderItemStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/cla [...]
index 90351f0f2df..c7430c1c0db 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedOrderItemStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedOrderItemStandardShardingAlgorithmFixture.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.example.extension.classbased.sharding.spring.b
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -33,13 +32,13 @@ public final class ClassBasedOrderItemStandardShardingAlgorithmFixture implement
private static final String SHARDING_COUNT = "sharding-count";
@Getter
- @Setter
private Properties props;
private Integer shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT), "%s can not be null.", SHARDING_COUNT);
shardingCount = Ints.tryParse(props.getProperty(SHARDING_COUNT));
Preconditions.checkArgument(null != shardingCount, "%s is not valid.", SHARDING_COUNT);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedOrderStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-b [...]
index 2b65795e176..feed2c1f075 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedOrderStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedOrderStandardShardingAlgorithmFixture.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.example.extension.classbased.sharding.spring.b
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -33,13 +32,13 @@ public final class ClassBasedOrderStandardShardingAlgorithmFixture implements St
private static final String SHARDING_COUNT = "sharding-count";
@Getter
- @Setter
private Properties props;
private Integer shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT), "%s can not be null.", SHARDING_COUNT);
shardingCount = Ints.tryParse(props.getProperty(SHARDING_COUNT));
Preconditions.checkArgument(null != shardingCount, "%s is not valid.", SHARDING_COUNT);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedDatasourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm- [...]
index e2ae24fa301..b78732399a3 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedDatasourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedDatasourceStandardShardingAlgorithmFixture.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.example.extension.classbased.sharding.spring.n
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -33,13 +32,13 @@ public final class ClassBasedDatasourceStandardShardingAlgorithmFixture implemen
private static final String SHARDING_COUNT = "sharding-count";
@Getter
- @Setter
private Properties props;
private Integer shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT), "%s can not be null.", SHARDING_COUNT);
shardingCount = Ints.tryParse(props.getProperty(SHARDING_COUNT));
Preconditions.checkArgument(null != shardingCount, "%s is not valid.", SHARDING_COUNT);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedOrderItemStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-e [...]
index c2466c912c1..9eab05dc206 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedOrderItemStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedOrderItemStandardShardingAlgorithmFixture.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.example.extension.classbased.sharding.spring.n
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -33,13 +32,13 @@ public final class ClassBasedOrderItemStandardShardingAlgorithmFixture implement
private static final String SHARDING_COUNT = "sharding-count";
@Getter
- @Setter
private Properties props;
private Integer shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT), "%s can not be null.", SHARDING_COUNT);
shardingCount = Ints.tryParse(props.getProperty(SHARDING_COUNT));
Preconditions.checkArgument(null != shardingCount, "%s is not valid.", SHARDING_COUNT);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedOrderStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-examp [...]
index ee268c59f54..4cc394ce60a 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedOrderStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedOrderStandardShardingAlgorithmFixture.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.example.extension.classbased.sharding.spring.n
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -33,13 +32,13 @@ public final class ClassBasedOrderStandardShardingAlgorithmFixture implements St
private static final String SHARDING_COUNT = "sharding-count";
@Getter
- @Setter
private Properties props;
private Integer shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT), "%s can not be null.", SHARDING_COUNT);
shardingCount = Ints.tryParse(props.getProperty(SHARDING_COUNT));
Preconditions.checkArgument(null != shardingCount, "%s is not valid.", SHARDING_COUNT);
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/raw/jdbc/fixture/SPIBasedStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-b [...]
index fb6d3b670aa..98ac14c67b7 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/raw/jdbc/fixture/SPIBasedStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/raw/jdbc/fixture/SPIBasedStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.extension.spibased.sharding.raw.jdbc.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SPIBasedStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
-
+
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based- [...]
index 1996fa3aaa6..8ea62ae8af5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SPIBasedDatasourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> dataSourceNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : dataSourceNames) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderItemStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-s [...]
index 3c38a6dfe67..385e4b6e391 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderItemStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderItemStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SPIBasedOrderItemStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Long> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Long> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-shard [...]
index 5b4574a4a70..a94bce265a1 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SPIBasedOrderStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Long> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Long> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedAccountStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-s [...]
index 970144c3525..a0fa65aa4a6 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedAccountStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedAccountStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SPIBasedAccountStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Long> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Long> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-base [...]
index df833eeb830..7de715e94d9 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SPIBasedDatasourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> dataSourceNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : dataSourceNames) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedOrderItemStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based [...]
index bf0554b58c4..85088298025 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedOrderItemStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedOrderItemStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SPIBasedOrderItemStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Long> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Long> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedOrderStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sha [...]
index 8c21313c50c..1bee463227d 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedOrderStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedOrderStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SPIBasedOrderStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Long> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Long> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/hint/ModuloHintShardingAlgorithm.java b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/hint/ModuloHintShardingAlgorithm.java
index 92906a083ba..49a1e27710e 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/hint/ModuloHintShardingAlgorithm.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/hint/ModuloHintShardingAlgorithm.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.sharding.raw.jdbc.hint;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import java.util.Collection;
import java.util.LinkedList;
+import java.util.Properties;
+@Getter
public final class ModuloHintShardingAlgorithm implements HintShardingAlgorithm<Long> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final HintShardingValue<Long> shardingValue) {
Collection<String> result = new LinkedList<>();
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/java/org/apache/shardingsphere/example/proxy/hint/ModuloHintShardingAlgorithm.java b/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/java/org/apache/shardingsphere/example/proxy/hint/ModuloHintShardingAlgorithm.java
index d2c99877c80..d514d61f207 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/java/org/apache/shardingsphere/example/proxy/hint/ModuloHintShardingAlgorithm.java
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/java/org/apache/shardingsphere/example/proxy/hint/ModuloHintShardingAlgorithm.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.example.proxy.hint;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import java.util.Collection;
import java.util.LinkedList;
+import java.util.Properties;
+@Getter
public final class ModuloHintShardingAlgorithm implements HintShardingAlgorithm<String> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final HintShardingValue<String> shardingValue) {
Collection<String> result = new LinkedList<>();
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/fixture/CoreDatabaseDiscoveryProviderAlgorithmFixture.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/fixture/CoreDatabaseDiscoveryProviderAlgorithmFixture.java
index aa8f52586f7..325164bd201 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/fixture/CoreDatabaseDiscoveryProviderAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/fixture/CoreDatabaseDiscoveryProviderAlgorithmFixture.java
@@ -17,13 +17,23 @@
package org.apache.shardingsphere.dbdiscovery.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
import org.apache.shardingsphere.dbdiscovery.spi.ReplicaDataSourceStatus;
import javax.sql.DataSource;
+import java.util.Properties;
+@Getter
public final class CoreDatabaseDiscoveryProviderAlgorithmFixture implements DatabaseDiscoveryProviderAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public void checkEnvironment(final String databaseName, final DataSource dataSource) {
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/DistSQLDatabaseDiscoveryProviderAlgorithmFixture.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/DistSQLD [...]
index 2baddcec59d..26945daad4e 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/DistSQLDatabaseDiscoveryProviderAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/DistSQLDatabaseDiscoveryProviderAlgorithmFixture.java
@@ -17,13 +17,23 @@
package org.apache.shardingsphere.dbdiscovery.distsql.handler.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
import org.apache.shardingsphere.dbdiscovery.spi.ReplicaDataSourceStatus;
import javax.sql.DataSource;
+import java.util.Properties;
+@Getter
public final class DistSQLDatabaseDiscoveryProviderAlgorithmFixture implements DatabaseDiscoveryProviderAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public void checkEnvironment(final String databaseName, final DataSource dataSource) {
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java
index 6baa28c025e..e374a9e1f09 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.dbdiscovery.mysql.type;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
import org.apache.shardingsphere.dbdiscovery.spi.ReplicaDataSourceStatus;
@@ -38,7 +37,6 @@ import java.util.Properties;
* MGR database discovery provider algorithm for MySQL.
*/
@Getter
-@Setter
@Slf4j
public final class MGRMySQLDatabaseDiscoveryProviderAlgorithm implements DatabaseDiscoveryProviderAlgorithm {
@@ -55,7 +53,12 @@ public final class MGRMySQLDatabaseDiscoveryProviderAlgorithm implements Databas
private static final String QUERY_CURRENT_MEMBER_STATE = "SELECT MEMBER_STATE FROM performance_schema.replication_group_members WHERE MEMBER_HOST=? AND MEMBER_PORT=?";
- private Properties props = new Properties();
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
@Override
public void checkEnvironment(final String databaseName, final DataSource dataSource) throws SQLException {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MySQLNormalReplicationDatabaseDiscoveryProvi [...]
index 19b99dc1de1..34388f58e79 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.dbdiscovery.mysql.type;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
import org.apache.shardingsphere.dbdiscovery.spi.ReplicaDataSourceStatus;
@@ -36,13 +35,17 @@ import java.util.Properties;
* Normal replication database discovery provider algorithm for MySQL.
*/
@Getter
-@Setter
@Slf4j
public final class MySQLNormalReplicationDatabaseDiscoveryProviderAlgorithm implements DatabaseDiscoveryProviderAlgorithm {
private static final String SHOW_SLAVE_STATUS = "SHOW SLAVE STATUS";
- private Properties props = new Properties();
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
@Override
public void checkEnvironment(final String databaseName, final DataSource dataSource) throws SQLException {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/test/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRDatabaseDiscoveryProviderAlgorithmTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/test/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRDatabaseDiscoveryProviderAlgorithmTest.java
index fb6bd88e847..d4bcbae2840 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/test/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRDatabaseDiscoveryProviderAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/test/java/org/apache/shardingsphere/dbdiscovery/mysql/type/MGRDatabaseDiscoveryProviderAlgorithmTest.java
@@ -17,12 +17,16 @@
package org.apache.shardingsphere.dbdiscovery.mysql.type;
+import org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
+import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
import org.apache.shardingsphere.dbdiscovery.spi.ReplicaDataSourceStatus;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.junit.Test;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
@@ -37,8 +41,9 @@ public final class MGRDatabaseDiscoveryProviderAlgorithmTest {
@Test
public void assertCheckEnvironment() throws SQLException {
- MGRMySQLDatabaseDiscoveryProviderAlgorithm actual = new MGRMySQLDatabaseDiscoveryProviderAlgorithm();
- actual.getProps().setProperty("group-name", "foo_group");
+ Properties props = new Properties();
+ props.setProperty("group-name", "foo_group");
+ DatabaseDiscoveryProviderAlgorithm actual = DatabaseDiscoveryProviderAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("MySQL.MGR", props));
actual.checkEnvironment("foo_db", mockEnvironmentAvailableDataSource());
}
@@ -57,7 +62,8 @@ public final class MGRDatabaseDiscoveryProviderAlgorithmTest {
@Test
public void assertIsPrimaryInstance() throws SQLException {
- assertTrue(new MGRMySQLDatabaseDiscoveryProviderAlgorithm().isPrimaryInstance(mockPrimaryDataSource()));
+ DatabaseDiscoveryProviderAlgorithm actual = DatabaseDiscoveryProviderAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("MySQL.MGR", new Properties()));
+ assertTrue(actual.isPrimaryInstance(mockPrimaryDataSource()));
}
private DataSource mockPrimaryDataSource() throws SQLException {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussNormalReplicationDatabaseDiscoveryProviderAlgorithm.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussNormalReplicationDatabase [...]
index d59a407e170..edf828ad3af 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussNormalReplicationDatabaseDiscoveryProviderAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussNormalReplicationDatabaseDiscoveryProviderAlgorithm.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.dbdiscovery.opengauss;
import lombok.Getter;
-import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
import org.apache.shardingsphere.dbdiscovery.spi.ReplicaDataSourceStatus;
@@ -34,13 +33,17 @@ import java.util.Properties;
* Normal replication database discovery provider algorithm for openGauss.
*/
@Getter
-@Setter
@Slf4j
public final class OpenGaussNormalReplicationDatabaseDiscoveryProviderAlgorithm implements DatabaseDiscoveryProviderAlgorithm {
private static final String QUERY_DB_ROLE = "SELECT local_role,db_state FROM pg_stat_get_stream_replications()";
- private Properties props = new Properties();
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
@Override
public void checkEnvironment(final String databaseName, final DataSource dataSource) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
index cad57ae62f2..2b865eaa44e 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.encrypt.algorithm;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import lombok.SneakyThrows;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
@@ -44,13 +43,13 @@ public final class AESEncryptAlgorithm implements EncryptAlgorithm<Object, Strin
private static final String AES_KEY = "aes-key-value";
@Getter
- @Setter
private Properties props;
- private volatile byte[] secretKey;
+ private byte[] secretKey;
@Override
public void init(final Properties props) {
+ this.props = props;
secretKey = createSecretKey(props);
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/MD5EncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/MD5EncryptAlgorithm.java
index 4ae791cdb9c..c8c1b95851a 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/MD5EncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/MD5EncryptAlgorithm.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.encrypt.algorithm;
import lombok.Getter;
-import lombok.Setter;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
@@ -29,11 +28,15 @@ import java.util.Properties;
* MD5 encrypt algorithm.
*/
@Getter
-@Setter
public final class MD5EncryptAlgorithm implements EncryptAlgorithm<Object, String> {
private Properties props;
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return null == plainValue ? null : DigestUtils.md5Hex(String.valueOf(plainValue));
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
index 49155f74118..f0e5e6fe66d 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.encrypt.algorithm;
import lombok.Getter;
-import lombok.Setter;
import org.apache.commons.codec.binary.Base64;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
@@ -40,7 +39,6 @@ public final class RC4EncryptAlgorithm implements EncryptAlgorithm<Object, Strin
private static final int KEY_MIN_LENGTH = 5;
@Getter
- @Setter
private Properties props;
private volatile byte[] key = new byte[SBOX_LENGTH - 1];
@@ -49,6 +47,7 @@ public final class RC4EncryptAlgorithm implements EncryptAlgorithm<Object, Strin
@Override
public void init(final Properties props) {
+ this.props = props;
reset();
setKey(props.getProperty(RC4_KEY, "").getBytes(StandardCharsets.UTF_8));
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreEncryptAlgorithmFixture.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreEncryptAlgorithmFixture.java
index 8218d50a768..e0c6e2caef5 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreEncryptAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreEncryptAlgorithmFixture.java
@@ -17,11 +17,22 @@
package org.apache.shardingsphere.encrypt.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
+import java.util.Properties;
+
+@Getter
public final class CoreEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return "encryptValue";
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryAssistedEncryptAlgorithmFixture.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryAssistedEncryptAlgorithmFixture.java
index 087735f4cc3..2a27df72989 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryAssistedEncryptAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryAssistedEncryptAlgorithmFixture.java
@@ -17,11 +17,22 @@
package org.apache.shardingsphere.encrypt.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.encrypt.spi.QueryAssistedEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
+import java.util.Properties;
+
+@Getter
public final class CoreQueryAssistedEncryptAlgorithmFixture implements QueryAssistedEncryptAlgorithm<Object, String> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return "encryptValue";
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreSchemaMetaDataAwareEncryptAlgorithmFixture.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreSchemaMetaDataAwareEncryptAlgorithmFixture.java
index 37b8dd11315..347f25235d9 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreSchemaMetaDataAwareEncryptAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreSchemaMetaDataAwareEncryptAlgorithmFixture.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.encrypt.fixture;
+import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
@@ -25,15 +26,24 @@ import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.rewrite.sql.token.generator.aware.SchemaMetaDataAware;
import java.util.Map;
+import java.util.Properties;
@Getter
@Setter
public final class CoreSchemaMetaDataAwareEncryptAlgorithmFixture implements EncryptAlgorithm<Integer, Integer>, SchemaMetaDataAware {
+ @Setter(AccessLevel.NONE)
+ private Properties props;
+
private String databaseName;
private Map<String, ShardingSphereSchema> schemas;
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Integer encrypt(final Integer plainValue, final EncryptContext encryptContext) {
return plainValue;
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
index aedfca08244..a08fdfba433 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.encrypt.sm.algorithm;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
import org.bouncycastle.crypto.digests.SM3Digest;
@@ -44,13 +43,13 @@ public final class SM3EncryptAlgorithm implements EncryptAlgorithm<Object, Strin
private static final int SALT_LENGTH = 8;
@Getter
- @Setter
private Properties props;
private byte[] sm3Salt;
@Override
public void init(final Properties props) {
+ this.props = props;
sm3Salt = createSm3Salt(props);
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
index 2f5da2d7bc8..0b6312d5ea9 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.encrypt.sm.algorithm;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import lombok.SneakyThrows;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
@@ -63,7 +62,6 @@ public final class SM4EncryptAlgorithm implements EncryptAlgorithm<Object, Strin
private static final Set<String> PADDINGS = new HashSet<>(Arrays.asList("PKCS5Padding", "PKCS7Padding"));
@Getter
- @Setter
private Properties props;
private byte[] sm4Key;
@@ -74,6 +72,7 @@ public final class SM4EncryptAlgorithm implements EncryptAlgorithm<Object, Strin
@Override
public void init(final Properties props) {
+ this.props = props;
String sm4Mode = createSm4Mode(props);
String sm4Padding = createSm4Padding(props);
sm4ModePadding = "SM4/" + sm4Mode + "/" + sm4Padding;
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RandomReplicaLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RandomReplicaLoadBalanceAlgorithm.java
index 043c4ac4afc..14c53b1a190 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RandomReplicaLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RandomReplicaLoadBalanceAlgorithm.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.readwritesplitting.spi.ReplicaLoadBalanceAlgorithm;
import java.util.List;
@@ -29,11 +28,15 @@ import java.util.concurrent.ThreadLocalRandom;
* Random replica load-balance algorithm.
*/
@Getter
-@Setter
public final class RandomReplicaLoadBalanceAlgorithm implements ReplicaLoadBalanceAlgorithm {
private Properties props = new Properties();
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String getDataSource(final String name, final String writeDataSourceName, final List<String> readDataSourceNames) {
return readDataSourceNames.get(ThreadLocalRandom.current().nextInt(readDataSourceNames.size()));
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RoundRobinReplicaLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RoundRobinReplicaLoadBalanceAlgorithm.java
index 8e4e8b42442..69a40a18c99 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RoundRobinReplicaLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RoundRobinReplicaLoadBalanceAlgorithm.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.readwritesplitting.spi.ReplicaLoadBalanceAlgorithm;
import java.util.List;
@@ -33,9 +32,13 @@ public final class RoundRobinReplicaLoadBalanceAlgorithm implements ReplicaLoadB
private final AtomicInteger count = new AtomicInteger(0);
@Getter
- @Setter
private Properties props;
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String getDataSource(final String name, final String writeDataSourceName, final List<String> readDataSourceNames) {
return readDataSourceNames.get(Math.abs(count.getAndIncrement()) % readDataSourceNames.size());
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java
index d4669fb6112..db95e3c9cad 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.readwritesplitting.spi.ReplicaLoadBalanceAlgorithm;
import java.util.Arrays;
@@ -31,14 +30,18 @@ import java.util.concurrent.ThreadLocalRandom;
* Weight replica load-balance algorithm.
*/
@Getter
-@Setter
public final class WeightReplicaLoadBalanceAlgorithm implements ReplicaLoadBalanceAlgorithm {
private static final double ACCURACY_THRESHOLD = 0.0001;
private static final ConcurrentHashMap<String, double[]> WEIGHT_MAP = new ConcurrentHashMap<>();
- private Properties props = new Properties();
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
@Override
public String getDataSource(final String name, final String writeDataSourceName, final List<String> readDataSourceNames) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/AbstractColumnMatchShadowAlgorithm.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/AbstractColumnMatchShadowAlgorithm.java
index 9b99d28d69d..afa4ec6216e 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/AbstractColumnMatchShadowAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/AbstractColumnMatchShadowAlgorithm.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;
import com.google.common.base.Preconditions;
+import lombok.Getter;
import org.apache.shardingsphere.shadow.algorithm.shadow.validator.ShadowValueValidator;
import org.apache.shardingsphere.shadow.algorithm.shadow.validator.column.ShadowDateValueValidator;
import org.apache.shardingsphere.shadow.algorithm.shadow.validator.column.ShadowEnumValueValidator;
@@ -41,12 +42,16 @@ public abstract class AbstractColumnMatchShadowAlgorithm implements ColumnShadow
private static final Collection<ShadowValueValidator> SHADOW_VALUE_VALIDATORS = new LinkedList<>();
+ @Getter
+ private Properties props;
+
private String shadowColumn;
private ShadowOperationType shadowOperationType;
@Override
public void init(final Properties props) {
+ this.props = props;
shadowColumn = getShadowColumn(props);
shadowOperationType = getShadowOperationType(props);
initShadowValueValidator();
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithm.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithm.java
index fb8aa50ddf3..e57105c7abd 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithm.java
@@ -18,8 +18,6 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;
import com.google.common.base.Preconditions;
-import lombok.Getter;
-import lombok.Setter;
import java.util.Properties;
import java.util.regex.Pattern;
@@ -31,10 +29,6 @@ public final class ColumnRegexMatchShadowAlgorithm extends AbstractColumnMatchSh
private static final String REGEX_PROPS_KEY = "regex";
- @Getter
- @Setter
- private Properties props;
-
private Pattern regex;
@Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
index 51886f9caa4..d6a2e1a578f 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
@@ -18,8 +18,6 @@
package org.apache.shardingsphere.shadow.algorithm.shadow.column;
import com.google.common.base.Preconditions;
-import lombok.Getter;
-import lombok.Setter;
import java.util.Properties;
@@ -30,10 +28,6 @@ public final class ColumnValueMatchShadowAlgorithm extends AbstractColumnMatchSh
private static final String VALUE_PROPS_KEY = "value";
- @Getter
- @Setter
- private Properties props;
-
private String shadowValue;
@Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithm.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithm.java
index 58ccc00b812..10d3d2db024 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.shadow.algorithm.shadow.hint;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.shadow.api.shadow.ShadowOperationType;
import org.apache.shardingsphere.shadow.api.shadow.hint.HintShadowAlgorithm;
import org.apache.shardingsphere.shadow.api.shadow.hint.PreciseHintShadowValue;
@@ -37,13 +36,13 @@ import java.util.Set;
public final class SimpleHintShadowAlgorithm implements HintShadowAlgorithm<String> {
@Getter
- @Setter
private Properties props;
private Map<String, String> simpleHint;
@Override
public void init(final Properties props) {
+ this.props = props;
checkPropsSize(props);
simpleHint = initSimpleHint(props);
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
index f8abb4a12f2..0146b68fe85 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
@@ -47,13 +47,13 @@ import static org.junit.Assert.assertTrue;
public class PropertiesShadowSpringBootStarterTest {
@Resource
- private AlgorithmProvidedShadowRuleConfiguration shadowRuleConfiguration;
+ private AlgorithmProvidedShadowRuleConfiguration shadowRuleConfig;
@Test
public void assertShadowRuleConfiguration() {
- assertShadowDataSources(shadowRuleConfiguration.getDataSources());
- assertShadowTables(shadowRuleConfiguration.getTables());
- assertShadowAlgorithms(shadowRuleConfiguration.getShadowAlgorithms());
+ assertShadowDataSources(shadowRuleConfig.getDataSources());
+ assertShadowTables(shadowRuleConfig.getTables());
+ assertShadowAlgorithms(shadowRuleConfig.getShadowAlgorithms());
}
private void assertShadowAlgorithms(final Map<String, ShadowAlgorithm> shadowAlgorithms) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowDefaultSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YamlShadowDefaultSpringBootStarterTest.java
similarity index 96%
rename from shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowDefaultSpringBootStarterTest.java
rename to shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YamlShadowDefaultSpringBootStarterTest.java
index cdd8127df34..74d9bd47448 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowDefaultSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YamlShadowDefaultSpringBootStarterTest.java
@@ -37,10 +37,10 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = YmlShadowDefaultSpringBootStarterTest.class)
+@SpringBootTest(classes = YamlShadowDefaultSpringBootStarterTest.class)
@SpringBootApplication
@ActiveProfiles("shadow-default")
-public class YmlShadowDefaultSpringBootStarterTest {
+public class YamlShadowDefaultSpringBootStarterTest {
@Resource
private AlgorithmProvidedShadowRuleConfiguration shadowRuleConfiguration;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
index 789cf60dd32..8c8ccfa79bd 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
@@ -69,12 +69,11 @@ public final class SnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgorithm
private static TimeService timeService = new TimeService();
@Getter
- @Setter
private Properties props;
- private volatile int maxVibrationOffset;
+ private int maxVibrationOffset;
- private volatile int maxTolerateTimeDifferenceMilliseconds;
+ private int maxTolerateTimeDifferenceMilliseconds;
private volatile int sequenceOffset = -1;
@@ -97,6 +96,7 @@ public final class SnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgorithm
@Override
public void init(final Properties props) {
+ this.props = props;
maxVibrationOffset = getMaxVibrationOffset(props);
maxTolerateTimeDifferenceMilliseconds = getMaxTolerateTimeDifferenceMilliseconds(props);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java
index b9b96b4ae50..e0415dd81f0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java
@@ -17,16 +17,26 @@
package org.apache.shardingsphere.sharding.algorithm.keygen;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
/**
* UUID key generate algorithm.
*/
+@Getter
public final class UUIDKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String generateKey() {
ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
index cee9c006a51..b73c28c1cc7 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.classbased;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
@@ -42,21 +41,21 @@ public final class ClassBasedShardingAlgorithm implements StandardShardingAlgori
private static final String ALGORITHM_CLASS_NAME_KEY = "algorithmClassName";
@Getter
- @Setter
private Properties props;
- private volatile ClassBasedShardingAlgorithmStrategyType strategy;
+ private ClassBasedShardingAlgorithmStrategyType strategy;
- private volatile String algorithmClassName;
+ private String algorithmClassName;
- private volatile StandardShardingAlgorithm standardShardingAlgorithm;
+ private StandardShardingAlgorithm standardShardingAlgorithm;
- private volatile ComplexKeysShardingAlgorithm complexKeysShardingAlgorithm;
+ private ComplexKeysShardingAlgorithm complexKeysShardingAlgorithm;
- private volatile HintShardingAlgorithm hintShardingAlgorithm;
+ private HintShardingAlgorithm hintShardingAlgorithm;
@Override
public void init(final Properties props) {
+ this.props = props;
strategy = getStrategy(props);
algorithmClassName = getAlgorithmClassName(props);
initAlgorithmInstance(props);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactory.java
index 2165fc98903..23e210c79ec 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactory.java
@@ -22,7 +22,6 @@ import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
-import org.apache.shardingsphere.spi.aware.SPIPropertiesAware;
import java.util.Properties;
@@ -44,22 +43,18 @@ public final class ClassBasedShardingAlgorithmFactory {
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
public static <T extends ShardingAlgorithm> T newInstance(final String shardingAlgorithmClassName, final Class<T> superShardingAlgorithmClass, final Properties props) {
- Class<?> result = Class.forName(shardingAlgorithmClassName);
- if (!superShardingAlgorithmClass.isAssignableFrom(result)) {
+ Class<?> algorithmClass = Class.forName(shardingAlgorithmClassName);
+ if (!superShardingAlgorithmClass.isAssignableFrom(algorithmClass)) {
throw new ShardingSphereException("Class %s should be implement %s", shardingAlgorithmClassName, superShardingAlgorithmClass.getName());
}
- T instance = (T) result.getDeclaredConstructor().newInstance();
- instance.init(props);
- setProperties(instance, props);
- return instance;
+ T result = (T) algorithmClass.getDeclaredConstructor().newInstance();
+ result.init(convertToStringTypedProperties(props));
+ return result;
}
- private static <T extends SPIPropertiesAware> void setProperties(final T instance, final Properties props) {
- if (null == props) {
- return;
- }
- Properties newProps = new Properties();
- props.forEach((key, value) -> newProps.setProperty(key.toString(), null == value ? null : value.toString()));
- instance.setProps(newProps);
+ private static Properties convertToStringTypedProperties(final Properties props) {
+ Properties result = new Properties();
+ props.forEach((key, value) -> result.setProperty(key.toString(), null == value ? null : value.toString()));
+ return result;
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
index d980f4f0921..d48f70def8a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
@@ -21,7 +21,6 @@ import com.google.common.base.Preconditions;
import groovy.lang.Closure;
import groovy.util.Expando;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.infra.expr.InlineExpressionParser;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
@@ -47,18 +46,18 @@ public final class ComplexInlineShardingAlgorithm implements ComplexKeysSharding
private static final String ALLOW_RANGE_QUERY_KEY = "allow-range-query-with-inline-sharding";
- private volatile String algorithmExpression;
+ @Getter
+ private Properties props;
- private volatile Collection<String> shardingColumns;
+ private String algorithmExpression;
- private volatile boolean allowRangeQuery;
+ private Collection<String> shardingColumns;
- @Getter
- @Setter
- private Properties props = new Properties();
+ private boolean allowRangeQuery;
@Override
public void init(final Properties props) {
+ this.props = props;
algorithmExpression = getAlgorithmExpression(props);
shardingColumns = getShardingColumns(props);
allowRangeQuery = getAllowRangeQuery(props);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
index fcfc9f95aeb..546e864efbd 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.datetime;
import com.google.common.base.Preconditions;
import com.google.common.collect.Range;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
@@ -51,18 +50,18 @@ public final class AutoIntervalShardingAlgorithm implements StandardShardingAlgo
private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@Getter
- @Setter
private Properties props;
- private volatile LocalDateTime dateTimeLower;
+ private LocalDateTime dateTimeLower;
- private volatile long shardingSeconds;
+ private long shardingSeconds;
@Getter
- private volatile int autoTablesAmount;
+ private int autoTablesAmount;
@Override
public void init(final Properties props) {
+ this.props = props;
dateTimeLower = getDateTime(props);
shardingSeconds = getShardingSeconds(props);
autoTablesAmount = (int) (Math.ceil((double) (parseDate(props.getProperty(DATE_TIME_UPPER_KEY)) / shardingSeconds)) + 2);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
index 7ef231bf76f..f971f818a02 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
@@ -21,7 +21,6 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.BoundType;
import com.google.common.collect.Range;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
@@ -57,25 +56,25 @@ public final class IntervalShardingAlgorithm implements StandardShardingAlgorith
private static final String INTERVAL_UNIT_KEY = "datetime-interval-unit";
@Getter
- @Setter
private Properties props;
- private volatile DateTimeFormatter dateTimeFormatter;
+ private DateTimeFormatter dateTimeFormatter;
- private volatile int dateTimePatternLength;
+ private int dateTimePatternLength;
- private volatile LocalDateTime dateTimeLower;
+ private LocalDateTime dateTimeLower;
- private volatile LocalDateTime dateTimeUpper;
+ private LocalDateTime dateTimeUpper;
- private volatile DateTimeFormatter tableSuffixPattern;
+ private DateTimeFormatter tableSuffixPattern;
- private volatile int stepAmount;
+ private int stepAmount;
- private volatile ChronoUnit stepUnit;
+ private ChronoUnit stepUnit;
@Override
public void init(final Properties props) {
+ this.props = props;
String dateTimePattern = getDateTimePattern(props);
dateTimeFormatter = DateTimeFormatter.ofPattern(dateTimePattern);
dateTimePatternLength = dateTimePattern.length();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
index fbdc315c1cb..01af9d132a5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
@@ -21,7 +21,6 @@ import com.google.common.base.Preconditions;
import groovy.lang.Closure;
import groovy.util.Expando;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.infra.expr.InlineExpressionParser;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
@@ -41,14 +40,14 @@ public final class HintInlineShardingAlgorithm implements HintShardingAlgorithm<
private static final String HINT_INLINE_VALUE_PROPERTY_NAME = "value";
- private volatile String algorithmExpression;
-
@Getter
- @Setter
private Properties props = new Properties();
+ private String algorithmExpression;
+
@Override
public void init(final Properties props) {
+ this.props = props;
algorithmExpression = getAlgorithmExpression(props);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
index 215870d7dea..b66fac5e24f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
@@ -22,7 +22,6 @@ import groovy.lang.Closure;
import groovy.lang.MissingMethodException;
import groovy.util.Expando;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.expr.InlineExpressionParser;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
@@ -42,15 +41,15 @@ public final class InlineShardingAlgorithm implements StandardShardingAlgorithm<
private static final String ALLOW_RANGE_QUERY_KEY = "allow-range-query-with-inline-sharding";
@Getter
- @Setter
private Properties props;
- private volatile String algorithmExpression;
+ private String algorithmExpression;
- private volatile boolean allowRangeQuery;
+ private boolean allowRangeQuery;
@Override
public void init(final Properties props) {
+ this.props = props;
algorithmExpression = getAlgorithmExpression(props);
allowRangeQuery = isAllowRangeQuery(props);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
index dab7a113315..26f910cf2de 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.mod;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
@@ -36,13 +35,13 @@ public final class HashModShardingAlgorithm implements StandardShardingAlgorithm
private static final String SHARDING_COUNT_KEY = "sharding-count";
@Getter
- @Setter
private Properties props;
- private volatile int shardingCount;
+ private int shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
shardingCount = getShardingCount(props);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
index ff96a31cc6e..12e3a260a0b 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.mod;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
@@ -37,13 +36,13 @@ public final class ModShardingAlgorithm implements StandardShardingAlgorithm<Com
private static final String SHARDING_COUNT_KEY = "sharding-count";
@Getter
- @Setter
private Properties props;
private volatile int shardingCount;
@Override
public void init(final Properties props) {
+ this.props = props;
shardingCount = getShardingCount(props);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
index e7e33b2f577..0a553195f85 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.range;
import com.google.common.collect.Range;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
@@ -34,10 +35,14 @@ import java.util.Properties;
*/
public abstract class AbstractRangeShardingAlgorithm implements StandardShardingAlgorithm<Comparable<?>>, ShardingAutoTableAlgorithm {
- private volatile Map<Integer, Range<Comparable<?>>> partitionRange;
+ @Getter
+ private Properties props;
+
+ private Map<Integer, Range<Comparable<?>>> partitionRange;
@Override
public final void init(final Properties props) {
+ this.props = props;
partitionRange = calculatePartitionRange(props);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
index 8a258bee5dd..8dbe7356c20 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
@@ -21,8 +21,6 @@ import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.Range;
import com.google.common.primitives.Longs;
-import lombok.Getter;
-import lombok.Setter;
import java.util.HashMap;
import java.util.List;
@@ -38,10 +36,6 @@ public final class BoundaryBasedRangeShardingAlgorithm extends AbstractRangeShar
private static final String SHARDING_RANGES_KEY = "sharding-ranges";
- @Getter
- @Setter
- private Properties props;
-
@Override
public Map<Integer, Range<Comparable<?>>> calculatePartitionRange(final Properties props) {
Preconditions.checkState(props.containsKey(SHARDING_RANGES_KEY), "Sharding ranges cannot be null.");
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
index 8b4f236f5bd..90cd104b78a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
@@ -20,8 +20,6 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.range;
import com.google.common.base.Preconditions;
import com.google.common.collect.Range;
import com.google.common.math.LongMath;
-import lombok.Getter;
-import lombok.Setter;
import java.math.RoundingMode;
import java.util.HashMap;
@@ -39,10 +37,6 @@ public final class VolumeBasedRangeShardingAlgorithm extends AbstractRangeShardi
private static final String SHARDING_VOLUME_KEY = "sharding-volume";
- @Getter
- @Setter
- private Properties props;
-
@Override
public Map<Integer, Range<Comparable<?>>> calculatePartitionRange(final Properties props) {
Preconditions.checkState(props.containsKey(RANGE_LOWER_KEY), "Lower range cannot be null.");
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedComplexKeysShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedComplexKeysShardingAlgorithmFixture.java
index b7a94e6571f..8deb46e3365 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedComplexKeysShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedComplexKeysShardingAlgorithmFixture.java
@@ -17,13 +17,23 @@
package org.apache.shardingsphere.sharding.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class ClassBasedComplexKeysShardingAlgorithmFixture implements ComplexKeysShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final ComplexKeysShardingValue<Integer> shardingValue) {
return availableTargetNames;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedHintShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedHintShardingAlgorithmFixture.java
index 3243fc35322..9339ee9c7db 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedHintShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedHintShardingAlgorithmFixture.java
@@ -17,13 +17,23 @@
package org.apache.shardingsphere.sharding.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class ClassBasedHintShardingAlgorithmFixture implements HintShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final HintShardingValue<Integer> shardingValue) {
return availableTargetNames;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedStandardShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedStandardShardingAlgorithmFixture.java
index 450172a6e18..9b270be0c4a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedStandardShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/ClassBasedStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.sharding.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class ClassBasedStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreComplexKeysShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreComplexKeysShardingAlgorithmFixture.java
index 5e730ac0921..828634bb46d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreComplexKeysShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreComplexKeysShardingAlgorithmFixture.java
@@ -17,13 +17,23 @@
package org.apache.shardingsphere.sharding.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class CoreComplexKeysShardingAlgorithmFixture implements ComplexKeysShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final ComplexKeysShardingValue<Integer> shardingValue) {
return availableTargetNames;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreHintShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreHintShardingAlgorithmFixture.java
index f959d19157c..b651374f046 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreHintShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreHintShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.sharding.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import java.util.Collection;
import java.util.Collections;
+import java.util.Properties;
+@Getter
public final class CoreHintShardingAlgorithmFixture implements HintShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final HintShardingValue<Integer> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreStandardShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreStandardShardingAlgorithmFixture.java
index 44228b8c2eb..3a68d58ecb0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreStandardShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/fixture/CoreStandardShardingAlgorithmFixture.java
@@ -17,15 +17,25 @@
package org.apache.shardingsphere.sharding.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Properties;
+@Getter
public final class CoreStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index ea419716ce3..773efae1e27 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -32,7 +32,6 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.algorithm.keygen.UUIDKeyGenerateAlgorithm;
-import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm;
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.ShardingTableRuleConfiguration;
@@ -322,18 +321,14 @@ public final class ShardingRuleTest {
shardingRuleConfig.getTables().add(shardingTableRuleConfig);
shardingRuleConfig.getTables().add(subTableRuleConfig);
shardingRuleConfig.getBindingTableGroups().add(shardingTableRuleConfig.getLogicTable() + "," + subTableRuleConfig.getLogicTable());
- InlineShardingAlgorithm shardingAlgorithmDB = new InlineShardingAlgorithm();
+ shardingTableRuleConfig.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("ds_id", "shardingAlgorithmDB"));
Properties shardingProps = new Properties();
shardingProps.setProperty("algorithm-expression", "ds_%{ds_id % 2}");
- shardingAlgorithmDB.setProps(shardingProps);
- shardingTableRuleConfig.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("ds_id", "shardingAlgorithmDB"));
- shardingRuleConfig.getShardingAlgorithms().put("shardingAlgorithmDB", new ShardingSphereAlgorithmConfiguration(shardingAlgorithmDB.getType(), shardingProps));
- InlineShardingAlgorithm subAlgorithmDB = new InlineShardingAlgorithm();
+ shardingRuleConfig.getShardingAlgorithms().put("shardingAlgorithmDB", new ShardingSphereAlgorithmConfiguration("INLINE", shardingProps));
+ subTableRuleConfig.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("ds_id", "subAlgorithmDB"));
Properties subProps = new Properties();
subProps.setProperty("algorithm-expression", "ds_%{ds_id % 3}");
- subAlgorithmDB.setProps(subProps);
- subTableRuleConfig.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("ds_id", "subAlgorithmDB"));
- shardingRuleConfig.getShardingAlgorithms().put("subAlgorithmDB", new ShardingSphereAlgorithmConfiguration(shardingAlgorithmDB.getType(), subProps));
+ shardingRuleConfig.getShardingAlgorithms().put("subAlgorithmDB", new ShardingSphereAlgorithmConfiguration("INLINE", subProps));
new ShardingRule(shardingRuleConfig, createDataSourceNames());
}
@@ -345,18 +340,14 @@ public final class ShardingRuleTest {
shardingRuleConfig.getTables().add(shardingTableRuleConfig);
shardingRuleConfig.getTables().add(subTableRuleConfig);
shardingRuleConfig.getBindingTableGroups().add(shardingTableRuleConfig.getLogicTable() + "," + subTableRuleConfig.getLogicTable());
- InlineShardingAlgorithm shardingAlgorithmTBL = new InlineShardingAlgorithm();
+ shardingTableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "shardingAlgorithmTBL"));
Properties shardingProps = new Properties();
shardingProps.setProperty("algorithm-expression", "table_%{table_id % 2}");
- shardingAlgorithmTBL.setProps(shardingProps);
- shardingTableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "shardingAlgorithmTBL"));
- shardingRuleConfig.getShardingAlgorithms().put("shardingAlgorithmTBL", new ShardingSphereAlgorithmConfiguration(shardingAlgorithmTBL.getType(), shardingProps));
- InlineShardingAlgorithm subAlgorithmTBL = new InlineShardingAlgorithm();
+ shardingRuleConfig.getShardingAlgorithms().put("shardingAlgorithmTBL", new ShardingSphereAlgorithmConfiguration("INLINE", shardingProps));
+ subTableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "subAlgorithmTBL"));
Properties subProps = new Properties();
subProps.setProperty("algorithm-expression", "table_%{table_id % 3}");
- subAlgorithmTBL.setProps(subProps);
- subTableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "subAlgorithmTBL"));
- shardingRuleConfig.getShardingAlgorithms().put("subAlgorithmTBL", new ShardingSphereAlgorithmConfiguration(subAlgorithmTBL.getType(), subProps));
+ shardingRuleConfig.getShardingAlgorithms().put("subAlgorithmTBL", new ShardingSphereAlgorithmConfiguration("INLINE", subProps));
new ShardingRule(shardingRuleConfig, createDataSourceNames());
}
@@ -368,18 +359,14 @@ public final class ShardingRuleTest {
shardingRuleConfig.getTables().add(shardingTableRuleConfig);
shardingRuleConfig.getTables().add(subTableRuleConfig);
shardingRuleConfig.getBindingTableGroups().add(shardingTableRuleConfig.getLogicTable() + "," + subTableRuleConfig.getLogicTable());
- InlineShardingAlgorithm shardingAlgorithmTBL = new InlineShardingAlgorithm();
+ shardingTableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "shardingAlgorithmTBL"));
Properties shardingProps = new Properties();
shardingProps.setProperty("algorithm-expression", "table_%{table_id % 2}");
- shardingAlgorithmTBL.setProps(shardingProps);
- shardingTableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "shardingAlgorithmTBL"));
- shardingRuleConfig.getShardingAlgorithms().put("shardingAlgorithmTBL", new ShardingSphereAlgorithmConfiguration(shardingAlgorithmTBL.getType(), shardingProps));
- InlineShardingAlgorithm subAlgorithmTBL = new InlineShardingAlgorithm();
- Properties subProps = new Properties();
- subProps.setProperty("algorithm-expression", "table_%{table_id % 3}");
- subAlgorithmTBL.setProps(subProps);
+ shardingRuleConfig.getShardingAlgorithms().put("shardingAlgorithmTBL", new ShardingSphereAlgorithmConfiguration("INLINE", shardingProps));
shardingRuleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "table_inline"));
shardingRuleConfig.setDefaultShardingColumn("table_id");
+ Properties subProps = new Properties();
+ subProps.setProperty("algorithm-expression", "table_%{table_id % 3}");
shardingRuleConfig.getShardingAlgorithms().put("table_inline", new ShardingSphereAlgorithmConfiguration("INLINE", subProps));
new ShardingRule(shardingRuleConfig, createDataSourceNames());
}
@@ -478,15 +465,7 @@ public final class ShardingRuleTest {
shardingRuleConfig.getTables().add(subTableRuleConfig);
shardingRuleConfig.getBindingTableGroups().add(shardingTableRuleConfig.getLogicTable() + "," + subTableRuleConfig.getLogicTable());
shardingRuleConfig.getBroadcastTables().add("BROADCAST_TABLE");
- InlineShardingAlgorithm shardingAlgorithmDB = new InlineShardingAlgorithm();
- Properties props = new Properties();
- props.setProperty("algorithm-expression", "ds_%{ds_id % 2}");
- shardingAlgorithmDB.setProps(props);
shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("ds_id", "standard"));
- InlineShardingAlgorithm shardingAlgorithmTBL = new InlineShardingAlgorithm();
- props = new Properties();
- props.setProperty("algorithm-expression", "table_%{table_id % 2}");
- shardingAlgorithmTBL.setProps(props);
shardingRuleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "standard"));
shardingRuleConfig.setDefaultShardingColumn("table_id");
shardingRuleConfig.setDefaultKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "default"));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/FixtureInputJobRateLimitAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/InputJobRateLimitAlgorithmFixture.java
similarity index 81%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/FixtureInputJobRateLimitAlgorithm.java
rename to shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/InputJobRateLimitAlgorithmFixture.java
index 29e5842b38e..aa738deb5a9 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/FixtureInputJobRateLimitAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/InputJobRateLimitAlgorithmFixture.java
@@ -17,12 +17,20 @@
package org.apache.shardingsphere.data.pipeline.spi.ratelimit;
+import lombok.Getter;
import org.apache.shardingsphere.data.pipeline.api.job.JobOperationType;
-/**
- * Fixture input job rate limit algorithm for SPI.
- */
-public final class FixtureInputJobRateLimitAlgorithm implements JobRateLimitAlgorithm {
+import java.util.Properties;
+
+@Getter
+public final class InputJobRateLimitAlgorithmFixture implements JobRateLimitAlgorithm {
+
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
@Override
public String getType() {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/FixtureOutputJobRateLimitAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/OutputJobRateLimitAlgorithmFixture.java
similarity index 81%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/FixtureOutputJobRateLimitAlgorithm.java
rename to shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/OutputJobRateLimitAlgorithmFixture.java
index 21bd978242a..518efcf56c4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/FixtureOutputJobRateLimitAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/OutputJobRateLimitAlgorithmFixture.java
@@ -17,12 +17,20 @@
package org.apache.shardingsphere.data.pipeline.spi.ratelimit;
+import lombok.Getter;
import org.apache.shardingsphere.data.pipeline.api.job.JobOperationType;
-/**
- * Fixture output job rate limit algorithm for SPI.
- */
-public final class FixtureOutputJobRateLimitAlgorithm implements JobRateLimitAlgorithm {
+import java.util.Properties;
+
+@Getter
+public final class OutputJobRateLimitAlgorithmFixture implements JobRateLimitAlgorithm {
+
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
@Override
public String getType() {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/keygen/DistSQLKeyGenerateAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/keygen/DistSQLKeyGenerateAlgorithmFixture.java
index 6afc3738e04..f28a9b8efcc 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/keygen/DistSQLKeyGenerateAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/keygen/DistSQLKeyGenerateAlgorithmFixture.java
@@ -17,10 +17,21 @@
package org.apache.shardingsphere.sharding.distsql.fixture.keygen;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import java.util.Properties;
+
+@Getter
public final class DistSQLKeyGenerateAlgorithmFixture implements KeyGenerateAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Comparable<?> generateKey() {
return 0L;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/BarDistSQLShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/BarDistSQLShardingAlgorithmFixture.java
index 1688ec6f2b1..e7773919da1 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/BarDistSQLShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/BarDistSQLShardingAlgorithmFixture.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.sharding.distsql.fixture.sharding;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
@@ -24,9 +25,18 @@ import org.apache.shardingsphere.sharding.api.sharding.standard.StandardSharding
import java.util.Collection;
import java.util.Collections;
+import java.util.Properties;
+@Getter
public final class BarDistSQLShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer>, ShardingAutoTableAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
return "";
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/FooDistSQLShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/FooDistSQLShardingAlgorithmFixture.java
index 36b4cb3f85b..5d3d96d5e11 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/FooDistSQLShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/FooDistSQLShardingAlgorithmFixture.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.sharding.distsql.fixture.sharding;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
@@ -24,9 +25,18 @@ import org.apache.shardingsphere.sharding.api.sharding.standard.StandardSharding
import java.util.Collection;
import java.util.Collections;
+import java.util.Properties;
+@Getter
public final class FooDistSQLShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer>, ShardingAutoTableAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
return "";
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.ratelimit.JobRateLimitAlgorithm b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.ratelimit.JobRateLimitAlgorithm
index ad296541421..bb6f4ce2de7 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.ratelimit.JobRateLimitAlgorithm
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.ratelimit.JobRateLimitAlgorithm
@@ -15,5 +15,5 @@
# limitations under the License.
#
-org.apache.shardingsphere.data.pipeline.spi.ratelimit.FixtureInputJobRateLimitAlgorithm
-org.apache.shardingsphere.data.pipeline.spi.ratelimit.FixtureOutputJobRateLimitAlgorithm
+org.apache.shardingsphere.data.pipeline.spi.ratelimit.InputJobRateLimitAlgorithmFixture
+org.apache.shardingsphere.data.pipeline.spi.ratelimit.OutputJobRateLimitAlgorithmFixture
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java
index 74ae7f6c2f5..51367d9cd27 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.sharding.cosid.algorithm.keygen;
import lombok.Getter;
-import lombok.Setter;
import me.ahoo.cosid.CosId;
import me.ahoo.cosid.provider.IdGeneratorProvider;
import me.ahoo.cosid.provider.LazyIdGenerator;
@@ -37,15 +36,15 @@ public final class CosIdKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
public static final String AS_STRING_KEY = "as-string";
@Getter
- @Setter
private Properties props;
- private volatile LazyIdGenerator lazyIdGenerator;
+ private LazyIdGenerator lazyIdGenerator;
- private volatile boolean asString;
+ private boolean asString;
@Override
public void init(final Properties props) {
+ this.props = props;
lazyIdGenerator = new LazyIdGenerator(props.getProperty(CosIdAlgorithmConstants.ID_NAME_KEY, IdGeneratorProvider.SHARE));
asString = Boolean.parseBoolean(props.getProperty(AS_STRING_KEY, Boolean.FALSE.toString()));
lazyIdGenerator.tryGet(false);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
index ee826d74a9e..2bfa8ce58dd 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.sharding.cosid.algorithm.keygen;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import me.ahoo.cosid.converter.Radix62IdConverter;
import me.ahoo.cosid.snowflake.ClockSyncSnowflakeId;
import me.ahoo.cosid.snowflake.MillisecondSnowflakeId;
@@ -47,14 +46,13 @@ public final class CosIdSnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgo
public static final String EPOCH_KEY = "epoch";
@Getter
- @Setter
private Properties props;
- private volatile SnowflakeId snowflakeId;
+ private SnowflakeId snowflakeId;
- private volatile boolean asString;
+ private boolean asString;
- private volatile long epoch;
+ private long epoch;
static {
Calendar calendar = Calendar.getInstance();
@@ -68,6 +66,7 @@ public final class CosIdSnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgo
@Override
public void init(final Properties props) {
+ this.props = props;
asString = getAsString(props);
epoch = getEpoch(props);
}
@@ -80,6 +79,14 @@ public final class CosIdSnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgo
return Long.parseLong(props.getProperty(EPOCH_KEY, DEFAULT_EPOCH + ""));
}
+ @Override
+ public void setInstanceContext(final InstanceContext instanceContext) {
+ long workerId = instanceContext.getWorkerId();
+ MillisecondSnowflakeId millisecondSnowflakeId =
+ new MillisecondSnowflakeId(epoch, MillisecondSnowflakeId.DEFAULT_TIMESTAMP_BIT, MillisecondSnowflakeId.DEFAULT_MACHINE_BIT, MillisecondSnowflakeId.DEFAULT_SEQUENCE_BIT, workerId);
+ snowflakeId = new StringSnowflakeId(new ClockSyncSnowflakeId(millisecondSnowflakeId), Radix62IdConverter.PAD_START);
+ }
+
@Override
public Comparable<?> generateKey() {
if (asString) {
@@ -93,14 +100,6 @@ public final class CosIdSnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgo
return snowflakeId;
}
- @Override
- public void setInstanceContext(final InstanceContext instanceContext) {
- long workerId = instanceContext.getWorkerId();
- MillisecondSnowflakeId millisecondSnowflakeId =
- new MillisecondSnowflakeId(epoch, MillisecondSnowflakeId.DEFAULT_TIMESTAMP_BIT, MillisecondSnowflakeId.DEFAULT_MACHINE_BIT, MillisecondSnowflakeId.DEFAULT_SEQUENCE_BIT, workerId);
- snowflakeId = new StringSnowflakeId(new ClockSyncSnowflakeId(millisecondSnowflakeId), Radix62IdConverter.PAD_START);
- }
-
@Override
public String getType() {
return TYPE;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java
index ff00b7f03f1..ede37f3aba7 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java
@@ -24,10 +24,10 @@ import lombok.AccessLevel;
import lombok.Getter;
import me.ahoo.cosid.sharding.IntervalStep;
import me.ahoo.cosid.sharding.IntervalTimeline;
-import org.apache.shardingsphere.sharding.cosid.algorithm.CosIdAlgorithmConstants;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import org.apache.shardingsphere.sharding.cosid.algorithm.CosIdAlgorithmConstants;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -57,6 +57,9 @@ public abstract class AbstractCosIdIntervalShardingAlgorithm<T extends Comparabl
public static final String ZONE_ID_KEY = "zone-id";
+ @Getter
+ private Properties props;
+
@Getter(AccessLevel.PROTECTED)
private volatile ZoneId zoneId;
@@ -64,6 +67,7 @@ public abstract class AbstractCosIdIntervalShardingAlgorithm<T extends Comparabl
@Override
public void init(final Properties props) {
+ this.props = props;
zoneId = getZoneId(props);
intervalTimeline = getIntervalTimeline(props);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdIntervalShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdIntervalShardingAlgorithm.java
index 815915e65fb..55a5d73489d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdIntervalShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdIntervalShardingAlgorithm.java
@@ -18,8 +18,6 @@
package org.apache.shardingsphere.sharding.cosid.algorithm.sharding.interval;
import com.google.common.base.Strings;
-import lombok.Getter;
-import lombok.Setter;
import me.ahoo.cosid.util.LocalDateTimeConvert;
import org.apache.shardingsphere.sharding.cosid.algorithm.CosIdAlgorithmConstants;
@@ -41,10 +39,6 @@ public final class CosIdIntervalShardingAlgorithm extends AbstractCosIdIntervalS
public static final String TIMESTAMP_UNIT_KEY = "ts-unit";
- @Getter
- @Setter
- private Properties props;
-
private volatile boolean isSecondTs;
private volatile DateTimeFormatter dateTimeFormatter;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java
index 2db3f9b4d54..c98a69af2e9 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java
@@ -18,8 +18,6 @@
package org.apache.shardingsphere.sharding.cosid.algorithm.sharding.interval;
import com.google.common.base.Strings;
-import lombok.Getter;
-import lombok.Setter;
import me.ahoo.cosid.converter.Radix62IdConverter;
import me.ahoo.cosid.snowflake.MillisecondSnowflakeId;
import me.ahoo.cosid.snowflake.MillisecondSnowflakeIdStateParser;
@@ -39,10 +37,6 @@ public final class CosIdSnowflakeIntervalShardingAlgorithm extends AbstractCosId
public static final String EPOCH_KEY = "epoch";
- @Getter
- @Setter
- private Properties props;
-
private volatile SnowflakeIdStateParser snowflakeIdStateParser;
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java
index a2e416d3a11..fc48498dccc 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java
@@ -19,12 +19,11 @@ package org.apache.shardingsphere.sharding.cosid.algorithm.sharding.mod;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import me.ahoo.cosid.sharding.ModCycle;
-import org.apache.shardingsphere.sharding.cosid.algorithm.CosIdAlgorithmConstants;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import org.apache.shardingsphere.sharding.cosid.algorithm.CosIdAlgorithmConstants;
import java.util.Collection;
import java.util.Properties;
@@ -39,13 +38,13 @@ public final class CosIdModShardingAlgorithm<T extends Number & Comparable<T>> i
public static final String MODULO_KEY = "mod";
@Getter
- @Setter
private Properties props;
- private volatile ModCycle<T> modCycle;
+ private ModCycle<T> modCycle;
@Override
public void init(final Properties props) {
+ this.props = props;
String divisorStr = getRequiredValue(props, MODULO_KEY);
int divisor = Integer.parseInt(divisorStr);
String logicNamePrefix = getRequiredValue(props, CosIdAlgorithmConstants.LOGIC_NAME_PREFIX_KEY);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-nanoid/src/main/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-nanoid/src/main/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithm.java
index 4ff26b95d9e..eefc9d3d99c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-nanoid/src/main/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-nanoid/src/main/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithm.java
@@ -18,15 +18,25 @@
package org.apache.shardingsphere.sharding.nanoid.algorithm.keygen;
import com.aventrix.jnanoid.jnanoid.NanoIdUtils;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import java.util.Properties;
import java.util.concurrent.ThreadLocalRandom;
/**
* NanoId key generate algorithm.
*/
+@Getter
public final class NanoIdKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String generateKey() {
return NanoIdUtils.randomNanoId(ThreadLocalRandom.current(), NanoIdUtils.DEFAULT_ALPHABET, NanoIdUtils.DEFAULT_SIZE);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/SpringComplexKeysShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/SpringComplexKeysShardingAlgorithmFixture.java
index 8d7b1e41449..87ba49ebe9f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/SpringComplexKeysShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/SpringComplexKeysShardingAlgorithmFixture.java
@@ -17,13 +17,23 @@
package org.apache.shardingsphere.sharding.spring.namespace.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SpringComplexKeysShardingAlgorithmFixture implements ComplexKeysShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final ComplexKeysShardingValue<Integer> shardingValue) {
return availableTargetNames;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/SpringHintShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/SpringHintShardingAlgorithmFixture.java
index 1e3f25a5ea0..863d5e7abb8 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/SpringHintShardingAlgorithmFixture.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/SpringHintShardingAlgorithmFixture.java
@@ -17,13 +17,23 @@
package org.apache.shardingsphere.sharding.spring.namespace.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class SpringHintShardingAlgorithmFixture implements HintShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final HintShardingValue<Integer> shardingValue) {
return availableTargetNames;
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/algorithm/ShardingSphereAlgorithm.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/algorithm/ShardingSphereAlgorithm.java
index 16830310024..0ec2830496a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/algorithm/ShardingSphereAlgorithm.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/algorithm/ShardingSphereAlgorithm.java
@@ -17,12 +17,11 @@
package org.apache.shardingsphere.infra.config.algorithm;
-import org.apache.shardingsphere.spi.aware.SPIPropertiesAware;
import org.apache.shardingsphere.spi.lifecycle.SPIPostProcessor;
import org.apache.shardingsphere.spi.type.typed.TypedSPI;
/**
* ShardingSphere algorithm.
*/
-public interface ShardingSphereAlgorithm extends TypedSPI, SPIPostProcessor, SPIPropertiesAware {
+public interface ShardingSphereAlgorithm extends TypedSPI, SPIPostProcessor {
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/algorithm/ShardingSphereAlgorithmFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/algorithm/ShardingSphereAlgorithmFactoryTest.java
index 6fff4a9e2cc..a23f07a04a3 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/algorithm/ShardingSphereAlgorithmFactoryTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/algorithm/ShardingSphereAlgorithmFactoryTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.infra.config.algorithm;
-import org.apache.shardingsphere.infra.config.fixture.FixtureShardingSphereAlgorithm;
+import org.apache.shardingsphere.infra.config.fixture.ShardingSphereAlgorithmFixture;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -40,7 +40,7 @@ public final class ShardingSphereAlgorithmFactoryTest {
Properties props = new Properties();
props.setProperty("key", "value");
ShardingSphereAlgorithm actual = ShardingSphereAlgorithmFactory.createAlgorithm(new ShardingSphereAlgorithmConfiguration("FIXTURE", props), ShardingSphereAlgorithm.class);
- assertThat(actual, instanceOf(FixtureShardingSphereAlgorithm.class));
- assertThat(((FixtureShardingSphereAlgorithm) actual).getTestValue(), is("value"));
+ assertThat(actual, instanceOf(ShardingSphereAlgorithmFixture.class));
+ assertThat(((ShardingSphereAlgorithmFixture) actual).getTestValue(), is("value"));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/fixture/FixtureShardingSphereAlgorithm.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/fixture/ShardingSphereAlgorithmFixture.java
similarity index 90%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/fixture/FixtureShardingSphereAlgorithm.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/fixture/ShardingSphereAlgorithmFixture.java
index 33e6d3d17f1..3d63a52ca8e 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/fixture/FixtureShardingSphereAlgorithm.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/fixture/ShardingSphereAlgorithmFixture.java
@@ -23,12 +23,15 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
import java.util.Properties;
@Getter
-public final class FixtureShardingSphereAlgorithm implements ShardingSphereAlgorithm {
+public final class ShardingSphereAlgorithmFixture implements ShardingSphereAlgorithm {
+
+ private Properties props;
private String testValue;
@Override
public void init(final Properties props) {
+ this.props = props;
testValue = props.getProperty("key");
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm
index 0625f592626..336749aed5a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.infra.config.fixture.FixtureShardingSphereAlgorithm
+org.apache.shardingsphere.infra.config.fixture.ShardingSphereAlgorithmFixture
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/encrypt/JDBCEncryptAlgorithmFixture.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/encrypt/JDBCEncryptAlgorithmFixture.java
index 930f30b8f06..55818b83987 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/encrypt/JDBCEncryptAlgorithmFixture.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/encrypt/JDBCEncryptAlgorithmFixture.java
@@ -17,11 +17,22 @@
package org.apache.shardingsphere.driver.fixture.encrypt;
+import lombok.Getter;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
+import java.util.Properties;
+
+@Getter
public final class JDBCEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return "encryptValue";
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/encrypt/JDBCQueryAssistedEncryptAlgorithmFixture.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/encrypt/JDBCQueryAssistedEncryptAlgorithmFixture.java
index d4f907724f4..a0621e3a4fb 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/encrypt/JDBCQueryAssistedEncryptAlgorithmFixture.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/encrypt/JDBCQueryAssistedEncryptAlgorithmFixture.java
@@ -17,11 +17,22 @@
package org.apache.shardingsphere.driver.fixture.encrypt;
+import lombok.Getter;
import org.apache.shardingsphere.encrypt.spi.QueryAssistedEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
+import java.util.Properties;
+
+@Getter
public final class JDBCQueryAssistedEncryptAlgorithmFixture implements QueryAssistedEncryptAlgorithm<Object, String> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return "encryptValue";
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/keygen/IncrementKeyGenerateAlgorithmFixture.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/keygen/IncrementKeyGenerateAlgorithmFixture.java
index fb46f45e9c7..dbc7e8a17a2 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/keygen/IncrementKeyGenerateAlgorithmFixture.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/keygen/IncrementKeyGenerateAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.driver.fixture.keygen;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
+@Getter
public final class IncrementKeyGenerateAlgorithmFixture implements KeyGenerateAlgorithm {
private final AtomicInteger count = new AtomicInteger();
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Comparable<?> generateKey() {
return count.incrementAndGet();
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/keygen/ResetIncrementKeyGenerateAlgorithmFixture.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/keygen/ResetIncrementKeyGenerateAlgorithmFixture.java
index 00dc2972484..82b5f61ce29 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/keygen/ResetIncrementKeyGenerateAlgorithmFixture.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/keygen/ResetIncrementKeyGenerateAlgorithmFixture.java
@@ -20,13 +20,22 @@ package org.apache.shardingsphere.driver.fixture.keygen;
import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
+@Getter
public final class ResetIncrementKeyGenerateAlgorithmFixture implements KeyGenerateAlgorithm {
@Getter
private static final AtomicInteger COUNT = new AtomicInteger();
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Comparable<?> generateKey() {
return COUNT.incrementAndGet();
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/sharding/JDBCStandardShardingAlgorithmFixture.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/sharding/JDBCStandardShardingAlgorithmFixture.java
index d4f3a2c8495..2049c1ca986 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/sharding/JDBCStandardShardingAlgorithmFixture.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/sharding/JDBCStandardShardingAlgorithmFixture.java
@@ -17,15 +17,25 @@
package org.apache.shardingsphere.driver.fixture.sharding;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Properties;
+@Getter
public final class JDBCStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/FixtureClusterPersistRepository.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/FixtureClusterPersistRepository.java
index 32f4566cf8a..8695da3a098 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/FixtureClusterPersistRepository.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/FixtureClusterPersistRepository.java
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.locks.Lock;
public final class FixtureClusterPersistRepository implements ClusterPersistRepository {
@@ -38,6 +39,15 @@ public final class FixtureClusterPersistRepository implements ClusterPersistRepo
registryData.put("/metadata", DefaultSchema.LOGIC_NAME);
}
+ @Override
+ public void init(final Properties props) {
+ }
+
+ @Override
+ public Properties getProps() {
+ return new Properties();
+ }
+
@Override
public String get(final String key) {
return registryData.get(key);
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/registry/AbstractAlgorithmProvidedBeanRegistry.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/registry/AbstractAlgorithmProvidedBeanRegistry.java
index 1b419587ef2..2739864767d 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/registry/AbstractAlgorithmProvidedBeanRegistry.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/registry/AbstractAlgorithmProvidedBeanRegistry.java
@@ -20,9 +20,9 @@ package org.apache.shardingsphere.spring.boot.registry;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
-import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
import org.apache.shardingsphere.spring.boot.util.PropertyUtil;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -31,10 +31,12 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.core.env.Environment;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
-import java.util.Set;
import java.util.stream.Collectors;
/**
@@ -53,34 +55,52 @@ public abstract class AbstractAlgorithmProvidedBeanRegistry<T extends ShardingSp
private final Environment environment;
+ private final Map<String, Properties> propsMap = new HashMap<>();
+
@SuppressWarnings("unchecked")
protected final void registerBean(final String prefix, final Class<T> algorithmClass, final BeanDefinitionRegistry registry) {
- boolean existPrefix = PropertyUtil.containPropertyPrefix(environment, prefix);
- if (existPrefix) {
- Map<String, Object> paramMap = PropertyUtil.handle(environment, prefix, Map.class);
- Set<String> keys = paramMap.keySet().stream().map(key -> key.contains(POINT) ? key.substring(0, key.indexOf(POINT)) : key).collect(Collectors.toSet());
- Map<String, YamlShardingSphereAlgorithmConfiguration> shardingAlgorithmMap = new LinkedHashMap<>();
- keys.forEach(each -> {
- YamlShardingSphereAlgorithmConfiguration config = new YamlShardingSphereAlgorithmConfiguration();
- String propsPrefix = String.join("", prefix, each, PROPS_SUFFIX);
- boolean existProps = PropertyUtil.containPropertyPrefix(environment, propsPrefix);
- if (existProps) {
- Map<String, Object> propsMap = PropertyUtil.handle(environment, propsPrefix, Map.class);
- config.getProps().putAll(propsMap);
- }
- String typePrefix = String.join("", prefix, each, TYPE_SUFFIX);
- String algorithmType = environment.getProperty(typePrefix);
- config.setType(algorithmType);
- shardingAlgorithmMap.put(each, config);
- });
- ShardingSphereServiceLoader.register(algorithmClass);
- shardingAlgorithmMap.forEach((key, value) -> {
- ShardingSphereAlgorithm algorithm = TypedSPIRegistry.getRegisteredService(algorithmClass, value.getType(), value.getProps());
- BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(algorithm.getClass());
- builder.addPropertyValue(PROPS, value.getProps());
- registry.registerBeanDefinition(key, builder.getBeanDefinition());
- });
+ if (!PropertyUtil.containPropertyPrefix(environment, prefix)) {
+ return;
+ }
+ Map<String, Object> parameterMap = PropertyUtil.handle(environment, prefix, Map.class);
+ Collection<String> algorithmNames = parameterMap.keySet().stream().map(key -> key.contains(POINT) ? key.substring(0, key.indexOf(POINT)) : key).collect(Collectors.toSet());
+ Map<String, ShardingSphereAlgorithmConfiguration> algorithmConfigs = createAlgorithmConfigurations(prefix, algorithmNames);
+ ShardingSphereServiceLoader.register(algorithmClass);
+ for (Entry<String, ShardingSphereAlgorithmConfiguration> entry : algorithmConfigs.entrySet()) {
+ ShardingSphereAlgorithmConfiguration algorithmConfig = entry.getValue();
+ BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ShardingSphereAlgorithmFactory.createAlgorithm(algorithmConfig, algorithmClass).getClass());
+ registry.registerBeanDefinition(entry.getKey(), builder.getBeanDefinition());
+ propsMap.put(entry.getKey(), algorithmConfig.getProps());
+ }
+ }
+
+ private Map<String, ShardingSphereAlgorithmConfiguration> createAlgorithmConfigurations(final String prefix, final Collection<String> algorithmNames) {
+ Map<String, ShardingSphereAlgorithmConfiguration> result = new LinkedHashMap<>(algorithmNames.size(), 1);
+ for (String each : algorithmNames) {
+ result.put(each, createAlgorithmConfiguration(prefix, each));
+ }
+ return result;
+ }
+
+ private ShardingSphereAlgorithmConfiguration createAlgorithmConfiguration(final String prefix, final String algorithmName) {
+ String type = environment.getProperty(String.join("", prefix, algorithmName, TYPE_SUFFIX));
+ Properties props = getProperties(prefix, algorithmName);
+ return new ShardingSphereAlgorithmConfiguration(type, props);
+ }
+
+ private Properties getProperties(final String prefix, final String algorithmName) {
+ String propsPrefix = String.join("", prefix, algorithmName, PROPS_SUFFIX);
+ Properties result = new Properties();
+ if (PropertyUtil.containPropertyPrefix(environment, propsPrefix)) {
+ result.putAll(PropertyUtil.handle(environment, propsPrefix, Map.class));
}
+ return convertToStringTypedProperties(result);
+ }
+
+ private Properties convertToStringTypedProperties(final Properties props) {
+ Properties result = new Properties();
+ props.forEach((key, value) -> result.setProperty(key.toString(), null == value ? null : value.toString()));
+ return result;
}
@Override
@@ -94,21 +114,9 @@ public abstract class AbstractAlgorithmProvidedBeanRegistry<T extends ShardingSp
@Override
public final Object postProcessAfterInitialization(final Object bean, final String beanName) {
- if (bean instanceof ShardingSphereAlgorithm) {
- ShardingSphereAlgorithm algorithm = (ShardingSphereAlgorithm) bean;
- Properties stringTypeProps = convertToStringTypedProperties(algorithm.getProps());
- algorithm.init(stringTypeProps);
- algorithm.setProps(stringTypeProps);
+ if (bean instanceof ShardingSphereAlgorithm && propsMap.containsKey(beanName)) {
+ ((ShardingSphereAlgorithm) bean).init(propsMap.get(beanName));
}
return bean;
}
-
- private static Properties convertToStringTypedProperties(final Properties props) {
- if (null == props) {
- return new Properties();
- }
- Properties result = new Properties();
- props.forEach((key, value) -> result.setProperty(key.toString(), null == value ? null : value.toString()));
- return result;
- }
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/FooShardingSphereFixtureAlgorithm.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/FooShardingSphereFixtureAlgorithm.java
index a8ef50c1ce4..74d4c5e86da 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/FooShardingSphereFixtureAlgorithm.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/FooShardingSphereFixtureAlgorithm.java
@@ -24,10 +24,13 @@ import java.util.Properties;
@Getter
public final class FooShardingSphereFixtureAlgorithm implements ShardingSphereFixtureAlgorithm {
+ private Properties props;
+
private String value;
@Override
public void init(final Properties props) {
+ this.props = props;
value = props.getProperty("fixture-value");
}
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithm.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithm.java
index 4be5b6fccbb..5ccc7388035 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithm.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.authority.provider.natived;
+import lombok.Getter;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.authority.provider.natived.builder.StoragePrivilegeBuilder;
import org.apache.shardingsphere.authority.spi.AuthorityProviderAlgorithm;
@@ -28,6 +29,7 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
import java.util.Optional;
+import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -38,8 +40,16 @@ import java.util.concurrent.ConcurrentHashMap;
@Deprecated
public final class NativeAuthorityProviderAlgorithm implements AuthorityProviderAlgorithm {
+ @Getter
+ private Properties props;
+
private final Map<ShardingSphereUser, ShardingSpherePrivileges> userPrivilegeMap = new ConcurrentHashMap<>();
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public void init(final Map<String, ShardingSphereMetaData> metaDataMap, final Collection<ShardingSphereUser> users) {
userPrivilegeMap.putAll(StoragePrivilegeBuilder.build(new LinkedList<>(metaDataMap.values()), users));
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/schema/SchemaPrivilegesPermittedAuthorityProviderAlgorithm.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/schema/SchemaPrivilegesPermittedAuthorityProviderAlgorithm.java
index 1f9e8673f7f..720728f14cd 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/schema/SchemaPrivilegesPermittedAuthorityProviderAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/schema/SchemaPrivilegesPermittedAuthorityProviderAlgorithm.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.authority.provider.schema;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.authority.provider.schema.builder.SchemaPrivilegeBuilder;
import org.apache.shardingsphere.authority.spi.AuthorityProviderAlgorithm;
@@ -39,12 +38,16 @@ public final class SchemaPrivilegesPermittedAuthorityProviderAlgorithm implement
public static final String PROP_USER_SCHEMA_MAPPINGS = "user-schema-mappings";
- private final Map<ShardingSphereUser, ShardingSpherePrivileges> userPrivilegeMap = new ConcurrentHashMap<>();
-
@Getter
- @Setter
private Properties props;
+ private final Map<ShardingSphereUser, ShardingSpherePrivileges> userPrivilegeMap = new ConcurrentHashMap<>();
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public void init(final Map<String, ShardingSphereMetaData> metaDataMap, final Collection<ShardingSphereUser> users) {
userPrivilegeMap.putAll(SchemaPrivilegeBuilder.build(users, props));
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesPermittedAuthorityProviderAlgorithm.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesPermittedAuthorityProviderAlgorithm.java
index e697847b547..8c40c53d0d7 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesPermittedAuthorityProviderAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesPermittedAuthorityProviderAlgorithm.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.authority.provider.simple;
+import lombok.Getter;
import org.apache.shardingsphere.authority.model.AccessSubject;
import org.apache.shardingsphere.authority.model.PrivilegeType;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
@@ -28,14 +29,23 @@ import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
+import java.util.Properties;
/**
* All privileges permitted authority provider algorithm.
*/
+@Getter
public final class AllPrivilegesPermittedAuthorityProviderAlgorithm implements AuthorityProviderAlgorithm {
private static final ShardingSpherePrivileges INSTANCE = new AllPrivilegesPermittedShardingSpherePrivileges();
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public void init(final Map<String, ShardingSphereMetaData> metaDataMap, final Collection<ShardingSphereUser> users) {
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/CRC32MatchDataConsistencyCalculateAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/CRC32MatchDataConsistencyCalculateAlgorithm.java
index f972d01cb4e..1d196f74fc6 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/CRC32MatchDataConsistencyCalculateAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/CRC32MatchDataConsistencyCalculateAlgorithm.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.data.pipeline.core.check.consistency.algorithm;
+import lombok.Getter;
import org.apache.shardingsphere.data.pipeline.api.check.consistency.DataConsistencyCalculateParameter;
import org.apache.shardingsphere.data.pipeline.core.exception.PipelineDataConsistencyCheckFailedException;
import org.apache.shardingsphere.data.pipeline.core.sqlbuilder.PipelineSQLBuilderFactory;
@@ -32,15 +33,24 @@ import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
+import java.util.Properties;
import java.util.stream.Collectors;
/**
* CRC32 match data consistency calculate algorithm.
*/
+@Getter
public final class CRC32MatchDataConsistencyCalculateAlgorithm implements DataConsistencyCalculateAlgorithm {
private static final Collection<String> SUPPORTED_DATABASE_TYPES = Collections.singletonList(new MySQLDatabaseType().getName());
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Iterable<Object> calculate(final DataConsistencyCalculateParameter parameter) {
PipelineSQLBuilder sqlBuilder = PipelineSQLBuilderFactory.newInstance(parameter.getDatabaseType());
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
index f71b177e599..1aa981fb676 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
@@ -55,10 +55,14 @@ public final class DataMatchDataConsistencyCalculateAlgorithm extends AbstractSt
private static final int DEFAULT_CHUNK_SIZE = 1000;
+ @Getter
+ private Properties props;
+
private int chunkSize;
@Override
public void init(final Properties props) {
+ this.props = props;
chunkSize = getChunkSize(props);
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/MemoryPipelineChannelCreator.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/MemoryPipelineChannelCreator.java
index 7ec3cd18e26..c18563af882 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/MemoryPipelineChannelCreator.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/MemoryPipelineChannelCreator.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.data.pipeline.core.ingest.channel.memory;
import com.google.common.base.Strings;
+import lombok.Getter;
import org.apache.shardingsphere.data.pipeline.api.ingest.channel.AckCallback;
import org.apache.shardingsphere.data.pipeline.api.ingest.channel.PipelineChannel;
import org.apache.shardingsphere.data.pipeline.spi.ingest.channel.PipelineChannelCreator;
@@ -33,10 +34,14 @@ public final class MemoryPipelineChannelCreator implements PipelineChannelCreato
private static final String BLOCK_QUEUE_SIZE_KEY = "block-queue-size";
+ @Getter
+ private Properties props;
+
private int blockQueueSize = 10000;
@Override
public void init(final Properties props) {
+ this.props = props;
String blockQueueSizeValue = props.getProperty(BLOCK_QUEUE_SIZE_KEY);
if (!Strings.isNullOrEmpty(blockQueueSizeValue)) {
blockQueueSize = Integer.parseInt(blockQueueSizeValue);
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/IdleRuleAlteredJobCompletionDetectAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/IdleRuleAlteredJobCompletionDetectAlgorithm.java
index f0dcb8c3483..fe3e1043416 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/IdleRuleAlteredJobCompletionDetectAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/IdleRuleAlteredJobCompletionDetectAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.data.pipeline.scenario.rulealtered.spi;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.data.pipeline.api.detect.RuleAlteredJobAlmostCompletedParameter;
import org.apache.shardingsphere.data.pipeline.api.ingest.position.FinishedPosition;
import org.apache.shardingsphere.data.pipeline.api.job.progress.JobProgress;
@@ -41,13 +40,13 @@ public final class IdleRuleAlteredJobCompletionDetectAlgorithm implements JobCom
private static final long DEFAULT_IDLE_SECONDS_THRESHOLD = 1800L;
@Getter
- @Setter
private Properties props;
private volatile long incrementalTaskIdleSecondsThreshold;
@Override
public void init(final Properties props) {
+ this.props = props;
incrementalTaskIdleSecondsThreshold = getIncrementalTaskIdleSecondsThreshold(props);
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithm.java
index 9b164a36e85..57c85102484 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithm.java
@@ -17,17 +17,27 @@
package org.apache.shardingsphere.traffic.algorithm.loadbalance;
+import lombok.Getter;
import org.apache.shardingsphere.infra.instance.definition.InstanceId;
import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
import java.util.List;
+import java.util.Properties;
import java.util.concurrent.ThreadLocalRandom;
/**
* Random traffic load balance algorithm.
*/
+@Getter
public final class RandomTrafficLoadBalanceAlgorithm implements TrafficLoadBalanceAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public InstanceId getInstanceId(final String name, final List<InstanceId> instanceIds) {
return instanceIds.get(ThreadLocalRandom.current().nextInt(instanceIds.size()));
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithm.java
index ffe2c7bffe5..2f0dd1ba9d4 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithm.java
@@ -17,10 +17,12 @@
package org.apache.shardingsphere.traffic.algorithm.loadbalance;
+import lombok.Getter;
import org.apache.shardingsphere.infra.instance.definition.InstanceId;
import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
import java.util.List;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -30,6 +32,14 @@ public final class RoundRobinTrafficLoadBalanceAlgorithm implements TrafficLoadB
private final AtomicInteger count = new AtomicInteger(0);
+ @Getter
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public InstanceId getInstanceId(final String name, final List<InstanceId> instanceIds) {
return instanceIds.get(Math.abs(count.getAndIncrement()) % instanceIds.size());
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/hint/SQLHintTrafficAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/hint/SQLHintTrafficAlgorithm.java
index 91bd4fc183c..240e685aba0 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/hint/SQLHintTrafficAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/hint/SQLHintTrafficAlgorithm.java
@@ -17,15 +17,26 @@
package org.apache.shardingsphere.traffic.algorithm.traffic.hint;
+import lombok.Getter;
import org.apache.shardingsphere.infra.hint.SQLHintPropertiesKey;
import org.apache.shardingsphere.traffic.api.traffic.hint.HintTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.hint.HintTrafficValue;
+import java.util.Properties;
+
/**
* Simple hint traffic algorithm.
*/
+@Getter
public final class SQLHintTrafficAlgorithm implements HintTrafficAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public boolean match(final HintTrafficValue hintTrafficValue) {
return hintTrafficValue.getSqlHintProps().getValue(SQLHintPropertiesKey.USE_TRAFFIC);
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithm.java
index 02266dedffb..576e43e0bba 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithm.java
@@ -21,7 +21,6 @@ import com.google.common.base.CharMatcher;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficValue;
@@ -40,13 +39,13 @@ public final class SQLMatchTrafficAlgorithm implements SegmentTrafficAlgorithm {
private static final String EXCLUDED_CHARACTERS = "[]`'\" ";
@Getter
- @Setter
private Properties props;
private Collection<String> sql;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(SQL_PROPS_KEY), "%s cannot be null.", SQL_PROPS_KEY);
sql = getExactlySQL(props.getProperty(SQL_PROPS_KEY));
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
index e83b1bcce0b..52b5ccf608d 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.traffic.algorithm.traffic.segment;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficValue;
@@ -34,13 +33,13 @@ public final class SQLRegexTrafficAlgorithm implements SegmentTrafficAlgorithm {
private static final String REGEX_PROPS_KEY = "regex";
@Getter
- @Setter
private Properties props;
private Pattern regex;
@Override
public void init(final Properties props) {
+ this.props = props;
Preconditions.checkArgument(props.containsKey(REGEX_PROPS_KEY), "%s can not be null.", REGEX_PROPS_KEY);
regex = Pattern.compile(props.getProperty(REGEX_PROPS_KEY));
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/FirstSQLTrafficAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/FirstSQLTrafficAlgorithm.java
index 99f1108b08a..a7cc1f2b7fe 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/FirstSQLTrafficAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/FirstSQLTrafficAlgorithm.java
@@ -17,15 +17,26 @@
package org.apache.shardingsphere.traffic.algorithm.traffic.transaction;
+import lombok.Getter;
import org.apache.shardingsphere.traffic.api.traffic.identifier.SimplifiedTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficValue;
+import java.util.Properties;
+
/**
* First SQL traffic algorithm.
*/
+@Getter
public final class FirstSQLTrafficAlgorithm implements TransactionTrafficAlgorithm, SimplifiedTrafficAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public boolean match(final TransactionTrafficValue transactionTrafficValue) {
return false;
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/JDBCTrafficAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/JDBCTrafficAlgorithm.java
index 9aa4000a42a..782673be32f 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/JDBCTrafficAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/JDBCTrafficAlgorithm.java
@@ -17,15 +17,26 @@
package org.apache.shardingsphere.traffic.algorithm.traffic.transaction;
+import lombok.Getter;
import org.apache.shardingsphere.traffic.api.traffic.identifier.SimplifiedTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficValue;
+import java.util.Properties;
+
/**
* JDBC traffic algorithm.
*/
+@Getter
public final class JDBCTrafficAlgorithm implements TransactionTrafficAlgorithm, SimplifiedTrafficAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public boolean match(final TransactionTrafficValue transactionTrafficValue) {
return transactionTrafficValue.isInTransaction();
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/ProxyTrafficAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/ProxyTrafficAlgorithm.java
index e826970c138..cf134dc491b 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/ProxyTrafficAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/ProxyTrafficAlgorithm.java
@@ -17,14 +17,25 @@
package org.apache.shardingsphere.traffic.algorithm.traffic.transaction;
+import lombok.Getter;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficAlgorithm;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficValue;
+import java.util.Properties;
+
/**
* Proxy traffic algorithm.
*/
+@Getter
public final class ProxyTrafficAlgorithm implements TransactionTrafficAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public boolean match(final TransactionTrafficValue transactionTrafficValue) {
return transactionTrafficValue.isInTransaction();
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/persist/PersistRepository.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/persist/PersistRepository.java
index b30ac2ea4c0..1fb5c525ded 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/persist/PersistRepository.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/persist/PersistRepository.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.mode.persist;
-import org.apache.shardingsphere.spi.aware.SPIPropertiesAware;
+import org.apache.shardingsphere.spi.lifecycle.SPIPostProcessor;
import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.util.List;
@@ -25,7 +25,7 @@ import java.util.List;
/**
* Persist repository.
*/
-public interface PersistRepository extends TypedSPI, SPIPropertiesAware {
+public interface PersistRepository extends TypedSPI, SPIPostProcessor {
/**
* Path separator.
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/fixture/ClusterPersistRepositoryFixture.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/fixture/ClusterPersistRepositoryFixture.java
index b08600d96d5..5c110dfc252 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/fixture/ClusterPersistRepositoryFixture.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/fixture/ClusterPersistRepositoryFixture.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEve
import java.util.Collections;
import java.util.List;
+import java.util.Properties;
import java.util.concurrent.locks.Lock;
public final class ClusterPersistRepositoryFixture implements ClusterPersistRepository {
@@ -32,6 +33,15 @@ public final class ClusterPersistRepositoryFixture implements ClusterPersistRepo
public void init(final ClusterPersistRepositoryConfiguration config) {
}
+ @Override
+ public void init(final Properties props) {
+ }
+
+ @Override
+ public Properties getProps() {
+ return new Properties();
+ }
+
@Override
public String get(final String key) {
return "";
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/process/ProcessListClusterPersistRepositoryFixture.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/process/ProcessListClusterPersistRepositoryFix [...]
index 22612f1134b..792314dd34f 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/ProcessListClusterPersistRepositoryFixture.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/process/ProcessListClusterPersistRepositoryFixture.java
@@ -18,14 +18,15 @@
package org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process;
import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
import org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEventListener;
-import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.locks.Lock;
public final class ProcessListClusterPersistRepositoryFixture implements ClusterPersistRepository {
@@ -36,6 +37,15 @@ public final class ProcessListClusterPersistRepositoryFixture implements Cluster
public void init(final ClusterPersistRepositoryConfiguration config) {
}
+ @Override
+ public void init(final Properties props) {
+ }
+
+ @Override
+ public Properties getProps() {
+ return new Properties();
+ }
+
@Override
public String get(final String key) {
return REGISTRY_DATA.get(key);
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-etcd/src/main/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepository.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mo [...]
index a82219176b8..6fe89b2993a 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-etcd/src/main/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepository.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-etcd/src/main/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepository.java
@@ -30,15 +30,14 @@ import io.etcd.jetcd.options.PutOption;
import io.etcd.jetcd.options.WatchOption;
import io.etcd.jetcd.watch.WatchEvent;
import lombok.Getter;
-import lombok.Setter;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
import org.apache.shardingsphere.mode.repository.cluster.etcd.lock.EtcdInternalLockHolder;
import org.apache.shardingsphere.mode.repository.cluster.etcd.props.EtcdProperties;
import org.apache.shardingsphere.mode.repository.cluster.etcd.props.EtcdPropertyKey;
-import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEvent;
import org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEventListener;
@@ -59,13 +58,17 @@ public final class EtcdRepository implements ClusterPersistRepository {
private Client client;
@Getter
- @Setter
private Properties props = new Properties();
private EtcdProperties etcdProps;
private EtcdInternalLockHolder etcdInternalLockHolder;
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public void init(final ClusterPersistRepositoryConfiguration config) {
etcdProps = new EtcdProperties(props);
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepository.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-prov [...]
index 7b0c36eacf9..a7bca6c2896 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepository.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepository.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.mode.repository.cluster.zookeeper;
import com.google.common.base.Strings;
import lombok.Getter;
-import lombok.Setter;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.CuratorFrameworkFactory.Builder;
@@ -69,9 +68,13 @@ public final class CuratorZookeeperRepository implements ClusterPersistRepositor
private ZookeeperInternalLockHolder internalLockHolder;
@Getter
- @Setter
private Properties props = new Properties();
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public void init(final ClusterPersistRepositoryConfiguration config) {
ZookeeperProperties zookeeperProps = new ZookeeperProperties(props);
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepositoryTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository- [...]
index 7004a41b858..d80f54385f2 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepositoryTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepositoryTest.java
@@ -268,7 +268,7 @@ public final class CuratorZookeeperRepositoryTest {
props.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "1000");
props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "2000");
ClusterPersistRepositoryConfiguration config = new ClusterPersistRepositoryConfiguration(REPOSITORY.getType(), "governance", SERVER_LISTS, new Properties());
- REPOSITORY.setProps(props);
+ REPOSITORY.init(props);
REPOSITORY.init(config);
assertThat(REPOSITORY.getProps().getProperty(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS.getKey()), is("1000"));
assertThat(REPOSITORY.getProps().getProperty(ZookeeperPropertyKey.MAX_RETRIES.getKey()), is("1"));
@@ -281,7 +281,7 @@ public final class CuratorZookeeperRepositoryTest {
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "0");
ClusterPersistRepositoryConfiguration config = new ClusterPersistRepositoryConfiguration(REPOSITORY.getType(), "governance", SERVER_LISTS, new Properties());
- REPOSITORY.setProps(props);
+ REPOSITORY.init(props);
REPOSITORY.init(config);
assertThat(REPOSITORY.getProps().getProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey()), is("0"));
}
@@ -291,7 +291,7 @@ public final class CuratorZookeeperRepositoryTest {
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "0");
ClusterPersistRepositoryConfiguration config = new ClusterPersistRepositoryConfiguration(REPOSITORY.getType(), "governance", SERVER_LISTS, new Properties());
- REPOSITORY.setProps(props);
+ REPOSITORY.init(props);
REPOSITORY.init(config);
assertThat(REPOSITORY.getProps().getProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey()), is("0"));
}
@@ -301,7 +301,7 @@ public final class CuratorZookeeperRepositoryTest {
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "any");
ClusterPersistRepositoryConfiguration config = new ClusterPersistRepositoryConfiguration(REPOSITORY.getType(), "governance", SERVER_LISTS, new Properties());
- REPOSITORY.setProps(props);
+ REPOSITORY.init(props);
REPOSITORY.init(config);
assertThat(REPOSITORY.getProps().getProperty(ZookeeperPropertyKey.DIGEST.getKey()), is("any"));
verify(builder).aclProvider(any(ACLProvider.class));
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/fixture/StandalonePersistRepositoryFixture.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/fixture/StandalonePersistRepositoryFixture.java
index b7bda3f1bec..b2d3f84cabf 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/fixture/StandalonePersistRepositoryFixture.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/fixture/StandalonePersistRepositoryFixture.java
@@ -23,10 +23,20 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
public final class StandalonePersistRepositoryFixture implements StandalonePersistRepository {
- private Map<String, String> persistMap = new HashMap<>();
+ private final Map<String, String> persistMap = new HashMap<>();
+
+ @Override
+ public void init(final Properties props) {
+ }
+
+ @Override
+ public Properties getProps() {
+ return new Properties();
+ }
@Override
public String get(final String key) {
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/main/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepository.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/s [...]
index 72e3a8de06f..ecae458681a 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/main/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepository.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/main/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepository.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.mode.repository.standalone.file;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
+import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
@@ -43,10 +44,14 @@ public final class FileRepository implements StandalonePersistRepository {
private static final String DEFAULT_PERSIST_DIRECTORY = ".shardingsphere";
+ @Getter
+ private Properties props;
+
private String path;
@Override
- public void setProps(final Properties props) {
+ public void init(final Properties props) {
+ this.props = props;
FileRepositoryProperties localRepositoryProps = new FileRepositoryProperties(props);
path = Optional.ofNullable(
Strings.emptyToNull(localRepositoryProps.getValue(FileRepositoryPropertyKey.PATH)))
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/test/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepositoryTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provid [...]
index b17de558fd6..7e6937a1548 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/test/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepositoryTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/test/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepositoryTest.java
@@ -37,7 +37,7 @@ public final class FileRepositoryTest {
public void setUp() {
Properties props = new Properties();
props.setProperty("path", "target");
- fileRepository.setProps(props);
+ fileRepository.init(props);
}
@Test
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2Repository.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardin [...]
index fad93ef1be0..182a6e13ad8 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2Repository.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2Repository.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.mode.repository.standalone.h2;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
+import lombok.Getter;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository;
@@ -50,6 +51,9 @@ public final class H2Repository implements StandalonePersistRepository {
private static final String SEPARATOR = "/";
+ @Getter
+ private Properties props;
+
private String jdbcUrl;
private String user;
@@ -59,7 +63,7 @@ public final class H2Repository implements StandalonePersistRepository {
private Connection connection;
@Override
- public void setProps(final Properties props) {
+ public void init(final Properties props) {
H2RepositoryProperties localRepositoryProps = new H2RepositoryProperties(props);
jdbcUrl = Optional.ofNullable(Strings.emptyToNull(localRepositoryProps.getValue(H2RepositoryPropertyKey.JDBC_URL))).orElse(DEFAULT_JDBC_URL);
user = Optional.ofNullable(Strings.emptyToNull(localRepositoryProps.getValue(H2RepositoryPropertyKey.USER))).orElse(DEFAULT_USER);
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/sha [...]
index 2e67800406f..84db61d8feb 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java
@@ -38,7 +38,7 @@ public final class H2RepositoryTest {
props.setProperty("user", "sa");
props.setProperty("password", "");
props.setProperty("driver_class", "org.h2.Driver");
- h2Repository.setProps(props);
+ h2Repository.init(props);
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficAlgorithmFixture.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficAlgorithmFixture.java
index 6a364bc459e..fd42d1bb72e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficAlgorithmFixture.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficAlgorithmFixture.java
@@ -17,10 +17,21 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
+import java.util.Properties;
+
+@Getter
public final class DistSQLTrafficAlgorithmFixture implements TrafficAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String getType() {
return "DISTSQL.FIXTURE";
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficLoadBalanceAlgorithmFixture.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficLoadBalanceAlgorithmFixture.java
index 66e301b72a5..f28d1adb77c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficLoadBalanceAlgorithmFixture.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficLoadBalanceAlgorithmFixture.java
@@ -17,13 +17,23 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.infra.instance.definition.InstanceId;
import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
import java.util.List;
+import java.util.Properties;
+@Getter
public final class DistSQLTrafficLoadBalanceAlgorithmFixture implements TrafficLoadBalanceAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String getType() {
return "DISTSQL.FIXTURE";
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/FixtureClusterPersistRepository.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/FixtureClusterPersistRepository.java
index 6ca96fa75a6..666fa2a6214 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/FixtureClusterPersistRepository.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/FixtureClusterPersistRepository.java
@@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.locks.Lock;
public final class FixtureClusterPersistRepository implements ClusterPersistRepository {
@@ -36,6 +37,15 @@ public final class FixtureClusterPersistRepository implements ClusterPersistRepo
public void init(final ClusterPersistRepositoryConfiguration config) {
}
+ @Override
+ public void init(final Properties props) {
+ }
+
+ @Override
+ public Properties getProps() {
+ return new Properties();
+ }
+
@Override
public String get(final String key) {
return REGISTRY_DATA.get(key);
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/aware/SPIPropertiesAware.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/aware/SPIPropertiesAware.java
deleted file mode 100644
index 99dac4c0c45..00000000000
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/aware/SPIPropertiesAware.java
+++ /dev/null
@@ -1,43 +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.spi.aware;
-
-import java.util.Properties;
-
-/**
- * SPI properties aware.
- */
-public interface SPIPropertiesAware {
-
- /**
- * Get properties.
- *
- * @return properties
- */
- default Properties getProps() {
- return new Properties();
- }
-
- /**
- * Set properties.
- *
- * @param props properties
- */
- default void setProps(Properties props) {
- }
-}
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/lifecycle/SPIPostProcessor.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/lifecycle/SPIPostProcessor.java
index 9280409f159..d949b8115e6 100644
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/lifecycle/SPIPostProcessor.java
+++ b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/lifecycle/SPIPostProcessor.java
@@ -29,6 +29,12 @@ public interface SPIPostProcessor {
*
* @param props properties to be initialized
*/
- default void init(Properties props) {
- }
+ void init(Properties props);
+
+ /**
+ * Get properties.
+ *
+ * @return properties
+ */
+ Properties getProps();
}
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
index 8b704fb9450..761d7c498d7 100644
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
+++ b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.spi.type.typed;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.aware.SPIPropertiesAware;
import org.apache.shardingsphere.spi.exception.ServiceProviderNotFoundException;
import org.apache.shardingsphere.spi.lifecycle.SPIPostProcessor;
@@ -66,9 +65,6 @@ public final class TypedSPIRegistry {
if (each instanceof SPIPostProcessor) {
((SPIPostProcessor) each).init(stringTypeProps);
}
- if (each instanceof SPIPropertiesAware) {
- ((SPIPropertiesAware) each).setProps(stringTypeProps);
- }
return Optional.of(each);
}
}
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/typed/fixture/TypedSPIFixtureImpl.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/typed/fixture/TypedSPIFixtureImpl.java
index c736f3829ee..848a04bb514 100644
--- a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/typed/fixture/TypedSPIFixtureImpl.java
+++ b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/typed/fixture/TypedSPIFixtureImpl.java
@@ -18,17 +18,20 @@
package org.apache.shardingsphere.spi.type.typed.fixture;
import lombok.Getter;
-import lombok.Setter;
import java.util.Collection;
import java.util.Collections;
import java.util.Properties;
@Getter
-@Setter
public final class TypedSPIFixtureImpl implements TypedSPIFixture {
- private Properties props = new Properties();
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
@Override
public String getType() {
diff --git a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/TestClusterPersistRepository.java b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/TestClusterPersistRepository.java
index 315140b5658..e980eec2f8c 100644
--- a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/TestClusterPersistRepository.java
+++ b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/TestClusterPersistRepository.java
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.locks.Lock;
public final class TestClusterPersistRepository implements ClusterPersistRepository {
@@ -38,6 +39,15 @@ public final class TestClusterPersistRepository implements ClusterPersistReposit
registryData.put("/metadata", DefaultSchema.LOGIC_NAME);
}
+ @Override
+ public void init(final Properties props) {
+ }
+
+ @Override
+ public Properties getProps() {
+ return new Properties();
+ }
+
@Override
public String get(final String key) {
return registryData.get(key);
diff --git a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/keygen/DriverKeyGenerateAlgorithmFixture.java b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/keygen/DriverKeyGenerateAlgorithmFixture.java
index 5ae8c7b9fa4..ac88900372e 100644
--- a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/keygen/DriverKeyGenerateAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/keygen/DriverKeyGenerateAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.driver.fixture.algorithm.keygen;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
+@Getter
public final class DriverKeyGenerateAlgorithmFixture implements KeyGenerateAlgorithm {
private static final AtomicInteger SEQUENCE = new AtomicInteger(100);
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Comparable<?> generateKey() {
return SEQUENCE.incrementAndGet();
diff --git a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/sharding/DriverComplexKeysShardingAlgorithmFixture.java b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/sharding/DriverComplexKeysShardingAlgorithmFixture.java
index 9afc8439281..56c14265a12 100644
--- a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/sharding/DriverComplexKeysShardingAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/sharding/DriverComplexKeysShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.driver.fixture.algorithm.sharding;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
import java.util.Collection;
import java.util.Collections;
+import java.util.Properties;
+@Getter
public final class DriverComplexKeysShardingAlgorithmFixture implements ComplexKeysShardingAlgorithm<String> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final ComplexKeysShardingValue<String> shardingValue) {
return Collections.emptyList();
diff --git a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/sharding/DriverStandardShardingAlgorithmFixture.java b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/sharding/DriverStandardShardingAlgorithmFixture.java
index 94d39630757..7c9349d77a6 100644
--- a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/sharding/DriverStandardShardingAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/java/org/apache/shardingsphere/driver/fixture/algorithm/sharding/DriverStandardShardingAlgorithmFixture.java
@@ -17,14 +17,24 @@
package org.apache.shardingsphere.driver.fixture.algorithm.sharding;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import java.util.Collection;
+import java.util.Properties;
+@Getter
public final class DriverStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/fixture/ITKeyGenerateAlgorithmFixture.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/fixture/ITKeyGenerateAlgorithmFixture.java
index 28997ddab5e..da8d3f0449a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/fixture/ITKeyGenerateAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/fixture/ITKeyGenerateAlgorithmFixture.java
@@ -17,10 +17,21 @@
package org.apache.shardingsphere.test.integration.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import java.util.Properties;
+
+@Getter
public final class ITKeyGenerateAlgorithmFixture implements KeyGenerateAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Long generateKey() {
return 1L;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/fixture/ITStandardShardingAlgorithmFixture.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/fixture/ITStandardShardingAlgorithmFixture.java
index cc5fbb5c049..2588e0c3d76 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/fixture/ITStandardShardingAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/fixture/ITStandardShardingAlgorithmFixture.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.test.integration.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -24,9 +25,18 @@ import org.apache.shardingsphere.sharding.api.sharding.standard.StandardSharding
import java.math.BigInteger;
import java.util.Collection;
import java.util.LinkedHashSet;
+import java.util.Properties;
+@Getter
public final class ITStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
for (String each : availableTargetNames) {
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/DataConsistencyCalculateAlgorithmFixture.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/DataConsistencyCalculateAlgorithmFixture.java
index cfdc4a56541..593ed925844 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/DataConsistencyCalculateAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/DataConsistencyCalculateAlgorithmFixture.java
@@ -17,15 +17,25 @@
package org.apache.shardingsphere.data.pipeline.core.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.data.pipeline.api.check.consistency.DataConsistencyCalculateParameter;
import org.apache.shardingsphere.data.pipeline.spi.check.consistency.DataConsistencyCalculateAlgorithm;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import java.util.Collection;
import java.util.Collections;
+import java.util.Properties;
+@Getter
public final class DataConsistencyCalculateAlgorithmFixture implements DataConsistencyCalculateAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Iterable<Object> calculate(final DataConsistencyCalculateParameter parameter) {
return Collections.singletonList(true);
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/FixtureJobCompletionDetectAlgorithm.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/JobCompletionDetectAlgorithmFixture.java
similarity index 82%
rename from shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/FixtureJobCompletionDetectAlgorithm.java
rename to shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/JobCompletionDetectAlgorithmFixture.java
index b82ef2c33b5..175491a90bf 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/FixtureJobCompletionDetectAlgorithm.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/fixture/JobCompletionDetectAlgorithmFixture.java
@@ -17,9 +17,20 @@
package org.apache.shardingsphere.data.pipeline.core.fixture;
+import lombok.Getter;
import org.apache.shardingsphere.data.pipeline.spi.detect.JobCompletionDetectAlgorithm;
-public final class FixtureJobCompletionDetectAlgorithm implements JobCompletionDetectAlgorithm<Object> {
+import java.util.Properties;
+
+@Getter
+public final class JobCompletionDetectAlgorithmFixture implements JobCompletionDetectAlgorithm<Object> {
+
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
@Override
public boolean isAlmostCompleted(final Object parameter) {
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.detect.JobCompletionDetectAlgorithm b/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.detect.JobCompletionDetectAlgorithm
index f75e6a721ec..a253ecc56cd 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.detect.JobCompletionDetectAlgorithm
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.detect.JobCompletionDetectAlgorithm
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.data.pipeline.core.fixture.FixtureJobCompletionDetectAlgorithm
+org.apache.shardingsphere.data.pipeline.core.fixture.JobCompletionDetectAlgorithmFixture
diff --git a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteNormalEncryptAlgorithmFixture.java b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteNormalEncryptAlgorithmFixture.java
index 65814727556..cda812f3861 100644
--- a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteNormalEncryptAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteNormalEncryptAlgorithmFixture.java
@@ -17,11 +17,22 @@
package org.apache.shardingsphere.sharding.rewrite.fixture.encrypt;
+import lombok.Getter;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
+import java.util.Properties;
+
+@Getter
public final class RewriteNormalEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return "encrypt_" + plainValue;
diff --git a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteQueryAssistedEncryptAlgorithmFixture.java b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteQueryAssistedEncryptAlgorithmFixture.java
index ac2ec6981f0..2b46e404b4e 100644
--- a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteQueryAssistedEncryptAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteQueryAssistedEncryptAlgorithmFixture.java
@@ -17,11 +17,22 @@
package org.apache.shardingsphere.sharding.rewrite.fixture.encrypt;
+import lombok.Getter;
import org.apache.shardingsphere.encrypt.spi.QueryAssistedEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
+import java.util.Properties;
+
+@Getter
public final class RewriteQueryAssistedEncryptAlgorithmFixture implements QueryAssistedEncryptAlgorithm<Object, String> {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return "encrypt_" + plainValue;
diff --git a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteSchemaMetaDataAwareEncryptAlgorithmFixture.java b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteSchemaMetaDataAwareEncryptAlgorithmFixture.java
index 28c8bb7f1d8..a023ddbc5f3 100644
--- a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteSchemaMetaDataAwareEncryptAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/encrypt/RewriteSchemaMetaDataAwareEncryptAlgorithmFixture.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.sharding.rewrite.fixture.encrypt;
+import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.context.EncryptContext;
@@ -25,14 +26,24 @@ import org.apache.shardingsphere.infra.metadata.schema.model.TableMetaData;
import org.apache.shardingsphere.infra.rewrite.sql.token.generator.aware.SchemaMetaDataAware;
import java.util.Map;
+import java.util.Properties;
-@Setter
public final class RewriteSchemaMetaDataAwareEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String>, SchemaMetaDataAware {
+ @Getter
+ private Properties props;
+
+ @Setter
private String databaseName;
+ @Setter
private Map<String, ShardingSphereSchema> schemas;
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
return "encrypt_" + plainValue + "_" + schemas.get(databaseName).get(encryptContext.getTableName()).getName();
diff --git a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/keygen/RewriteKeyGenerateAlgorithmFixture.java b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/keygen/RewriteKeyGenerateAlgorithmFixture.java
index d78825460d7..239185305ec 100644
--- a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/keygen/RewriteKeyGenerateAlgorithmFixture.java
+++ b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/keygen/RewriteKeyGenerateAlgorithmFixture.java
@@ -17,10 +17,21 @@
package org.apache.shardingsphere.sharding.rewrite.fixture.keygen;
+import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import java.util.Properties;
+
+@Getter
public final class RewriteKeyGenerateAlgorithmFixture implements KeyGenerateAlgorithm {
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ }
+
@Override
public Long generateKey() {
return 1L;