diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration.cn.md
index 9cc71819a773f..cf10cca4ccb62 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration.cn.md
@@ -13,10 +13,7 @@ weight = 12
{{% tab name="语法" %}}
```sql
ExportDatabaseConfiguration ::=
- 'IMPORT' 'DATABASE' 'CONFIGURATION' 'FROM' 'FILE' filePath ('TO' databaseName)?
-
-databaseName ::=
- identifier
+ 'IMPORT' 'DATABASE' 'CONFIGURATION' 'FROM' 'FILE' filePath
filePath ::=
string
@@ -38,7 +35,7 @@ filePath ::=
- 将 `YAML` 中的配置导入到指定逻辑库中
```sql
-IMPORT DATABASE CONFIGURATION FROM FILE "/xxx/config_sharding_db.yaml" TO sharding_db;
+IMPORT DATABASE CONFIGURATION FROM FILE "/xxx/config_sharding_db.yaml";
```
- 将 `YAML` 中的配置导入到当前逻辑库中
@@ -49,8 +46,8 @@ IMPORT DATABASE CONFIGURATION FROM FILE "/xxx/config_sharding_db.yaml";
### 保留字
-`IMPORT`、`DATABASE`、`CONFIGURATION`、`FROM`、`FILE`、`TO`
+`IMPORT`、`DATABASE`、`CONFIGURATION`、`FROM`、`FILE`
### 相关链接
-- [保留字](/cn/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/)
\ No newline at end of file
+- [保留字](/cn/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/)
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration.en.md
index fda7344b777fe..66c057f539bff 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration.en.md
@@ -13,10 +13,7 @@ The `IMPORT DATABASE CONFIGURATION` syntax is used to import `YAML` configuratio
{{% tab name="Grammar" %}}
```sql
ExportDatabaseConfiguration ::=
- 'IMPORT' 'DATABASE' 'CONFIGURATION' 'FROM' 'FILE' filePath ('TO' databaseName)?
-
-databaseName ::=
- identifier
+ 'IMPORT' 'DATABASE' 'CONFIGURATION' 'FROM' 'FILE' filePath
filePath ::=
string
@@ -38,7 +35,7 @@ filePath ::=
- Import the configuration in `YAML` into the specified database
```sql
-IMPORT DATABASE CONFIGURATION FROM FILE "/xxx/config_sharding_db.yaml" TO sharding_db;
+IMPORT DATABASE CONFIGURATION FROM FILE "/xxx/config_sharding_db.yaml";
```
- Import the configuration in `YAML` into the current database
@@ -49,7 +46,7 @@ IMPORT DATABASE CONFIGURATION FROM FILE "/xxx/config_sharding_db.yaml";
### Reserved word
-`IMPORT`, `DATABASE`, `CONFIGURATION`, `FROM`, `FILE`, `TO`
+`IMPORT`, `DATABASE`, `CONFIGURATION`, `FROM`, `FILE`
### Related links
diff --git a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
index a334774dc1d99..02d4d7ff7e317 100644
--- a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
+++ b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
@@ -58,7 +58,7 @@ void assertGetRowData() {
assertThat(row.getCell(4), is("user_assisted"));
assertThat(row.getCell(5), is("user_like"));
assertThat(row.getCell(6), is("md5"));
- assertThat(row.getCell(7), is("{}"));
+ assertThat(row.getCell(7), is(""));
assertThat(row.getCell(8), is(""));
assertThat(row.getCell(9), is(""));
assertThat(row.getCell(10), is(""));
diff --git a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
index 096704a189fdc..a6e59fc54e54f 100644
--- a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
+++ b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
@@ -55,7 +55,7 @@ void assertGetRowData() {
assertThat(row.getCell(1), is("t_mask"));
assertThat(row.getCell(2), is("user_id"));
assertThat(row.getCell(3), is("md5"));
- assertThat(row.getCell(4), is("{}"));
+ assertThat(row.getCell(4), is(""));
}
@Test
diff --git a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
index 91270ddc484db..593cabbd9f8fe 100644
--- a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
+++ b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
@@ -56,14 +56,14 @@ void assertGetRowData() {
assertThat(row.getCell(3), is("source"));
assertThat(row.getCell(4), is("shadow"));
assertThat(row.getCell(5), is("REGEX_MATCH"));
- assertThat(row.getCell(6), is("{}"));
+ assertThat(row.getCell(6), is(""));
row = iterator.next();
assertThat(row.getCell(1), is("t_order_item"));
assertThat(row.getCell(2), is("shadow_rule"));
assertThat(row.getCell(3), is("source"));
assertThat(row.getCell(4), is("shadow"));
assertThat(row.getCell(5), is("REGEX_MATCH"));
- assertThat(row.getCell(6), is("{}"));
+ assertThat(row.getCell(6), is(""));
}
@Test
diff --git a/features/sharding/core/pom.xml b/features/sharding/core/pom.xml
index 00a10e4d655a7..ccfb28a8a3982 100644
--- a/features/sharding/core/pom.xml
+++ b/features/sharding/core/pom.xml
@@ -83,6 +83,16 @@
shardingsphere-infra-expr-core
${project.version}
+
+ org.apache.shardingsphere
+ shardingsphere-infra-key-generator-uuid
+ ${project.version}
+
+
+ org.apache.shardingsphere
+ shardingsphere-infra-key-generator-snowflake
+ ${project.version}
+
org.apache.shardingsphere
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java
index 14ecbe373768c..eb0e9688b7f59 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java
@@ -19,6 +19,7 @@
import lombok.Setter;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContextDecorator;
@@ -39,15 +40,16 @@ public final class ShardingSQLRewriteContextDecorator implements SQLRewriteConte
@Override
public void decorate(final ShardingRule shardingRule, final ConfigurationProperties props, final SQLRewriteContext sqlRewriteContext, final RouteContext routeContext) {
- if (!containsShardingTable(shardingRule, sqlRewriteContext.getSqlStatementContext())) {
+ SQLStatementContext sqlStatementContext = sqlRewriteContext.getSqlStatementContext();
+ if (sqlStatementContext instanceof InsertStatementContext && !containsShardingTable(shardingRule, sqlStatementContext)) {
return;
}
if (!sqlRewriteContext.getParameters().isEmpty()) {
Collection parameterRewriters =
- new ShardingParameterRewriterBuilder(shardingRule, routeContext, sqlRewriteContext.getDatabase().getSchemas(), sqlRewriteContext.getSqlStatementContext()).getParameterRewriters();
+ new ShardingParameterRewriterBuilder(shardingRule, routeContext, sqlRewriteContext.getDatabase().getSchemas(), sqlStatementContext).getParameterRewriters();
rewriteParameters(sqlRewriteContext, parameterRewriters);
}
- sqlRewriteContext.addSQLTokenGenerators(new ShardingTokenGenerateBuilder(shardingRule, routeContext, sqlRewriteContext.getSqlStatementContext()).getSQLTokenGenerators());
+ sqlRewriteContext.addSQLTokenGenerators(new ShardingTokenGenerateBuilder(shardingRule, routeContext, sqlStatementContext).getSQLTokenGenerators());
}
private boolean containsShardingTable(final ShardingRule shardingRule, final SQLStatementContext sqlStatementContext) {
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index 2b38f3e591ef8..e1f69d895675e 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -36,6 +36,8 @@
import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.core.exception.algorithm.GenerateKeyStrategyNotFoundException;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
@@ -48,11 +50,9 @@
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.cache.ShardingCache;
-import org.apache.shardingsphere.sharding.exception.algorithm.keygen.GenerateKeyStrategyNotFoundException;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.metadata.InvalidBindingTablesException;
import org.apache.shardingsphere.sharding.exception.metadata.ShardingTableRuleNotFoundException;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import org.apache.shardingsphere.sharding.spi.ShardingAuditAlgorithm;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/AutoIncrementKeyGenerateAlgorithmFixture.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/AutoIncrementKeyGenerateAlgorithmFixture.java
index f593618cf1717..a2533d6c055b5 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/AutoIncrementKeyGenerateAlgorithmFixture.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/AutoIncrementKeyGenerateAlgorithmFixture.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.algorithm.keygen.fixture;
import lombok.Getter;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
import java.util.concurrent.atomic.AtomicInteger;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecoratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecoratorTest.java
index 221f51abb7a80..7ad1b58e9f385 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecoratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecoratorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sharding.rewrite.context;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
@@ -26,6 +27,7 @@
import org.junit.jupiter.api.Test;
import java.util.Collections;
+import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -43,4 +45,16 @@ void assertDecorate() {
new ShardingSQLRewriteContextDecorator().decorate(mock(ShardingRule.class), mock(ConfigurationProperties.class), sqlRewriteContext, mock(RouteContext.class));
assertTrue(sqlRewriteContext.getSqlTokens().isEmpty());
}
+
+ @Test
+ void assertDecorateWhenInsertStatementNotContainsShardingTable() {
+ SQLRewriteContext sqlRewriteContext = mock(SQLRewriteContext.class);
+ InsertStatementContext insertStatementContext = mock(InsertStatementContext.class, RETURNS_DEEP_STUBS);
+ when(insertStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_order"));
+ when(sqlRewriteContext.getSqlStatementContext()).thenReturn(insertStatementContext);
+ ShardingRule shardingRule = mock(ShardingRule.class);
+ when(shardingRule.findTableRule("t_order")).thenReturn(Optional.empty());
+ new ShardingSQLRewriteContextDecorator().decorate(shardingRule, mock(ConfigurationProperties.class), sqlRewriteContext, mock(RouteContext.class));
+ assertTrue(sqlRewriteContext.getSqlTokens().isEmpty());
+ }
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index 2281e541c4029..8ec0df9b69f12 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -29,9 +29,10 @@
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.keygen.core.exception.algorithm.GenerateKeyStrategyNotFoundException;
+import org.apache.shardingsphere.keygen.snowflake.algorithm.SnowflakeKeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.uuid.algorithm.UUIDKeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.algorithm.audit.DMLShardingConditionsShardingAuditAlgorithm;
-import org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
-import org.apache.shardingsphere.sharding.algorithm.keygen.UUIDKeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
@@ -42,7 +43,6 @@
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import org.apache.shardingsphere.sharding.exception.algorithm.keygen.GenerateKeyStrategyNotFoundException;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
import org.apache.shardingsphere.sharding.exception.metadata.InvalidBindingTablesException;
import org.apache.shardingsphere.sharding.exception.metadata.ShardingTableRuleNotFoundException;
diff --git a/features/sharding/core/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm b/features/sharding/core/src/test/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
similarity index 100%
rename from features/sharding/core/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
rename to features/sharding/core/src/test/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index 22dfe5cfca058..deed64a6b8c44 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -32,6 +32,7 @@
import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
@@ -56,7 +57,6 @@
import org.apache.shardingsphere.sharding.exception.strategy.InvalidShardingStrategyConfigurationException;
import org.apache.shardingsphere.sharding.rule.BindingTableCheckedConfiguration;
import org.apache.shardingsphere.sharding.rule.TableRule;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import org.apache.shardingsphere.sharding.spi.ShardingAuditAlgorithm;
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/keygen/DistSQLKeyGenerateAlgorithmFixture.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/keygen/DistSQLKeyGenerateAlgorithmFixture.java
index 6afc3738e045e..4bbd012d604e2 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/keygen/DistSQLKeyGenerateAlgorithmFixture.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/keygen/DistSQLKeyGenerateAlgorithmFixture.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.distsql.fixture.keygen;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
public final class DistSQLKeyGenerateAlgorithmFixture implements KeyGenerateAlgorithm {
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
index 63e737d7de863..353d56c86e958 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
@@ -69,7 +69,7 @@ void assertGetRowData() {
assertThat(row.getCell(11), is("{\"algorithm-expression\":\"t_order_${order_id % 2}\"}"));
assertThat(row.getCell(12), is("order_id"));
assertThat(row.getCell(13), is("SNOWFLAKE"));
- assertThat(row.getCell(14), is("{}"));
+ assertThat(row.getCell(14), is(""));
assertThat(row.getCell(15), is("DML_SHARDING_CONDITIONS"));
assertThat(row.getCell(16), is("true"));
}
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
index 40b33b7bce985..ea1b40a2c3a3d 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
@@ -53,7 +53,7 @@ void assertGetRowData() {
LocalDataQueryResultRow row = iterator.next();
assertThat(row.getCell(1), is("uuid_key_generator"));
assertThat(row.getCell(2), is("UUID"));
- assertThat(row.getCell(3), is("{}"));
+ assertThat(row.getCell(3), is(""));
}
@Test
diff --git a/features/sharding/distsql/handler/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm b/features/sharding/distsql/handler/src/test/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
similarity index 100%
rename from features/sharding/distsql/handler/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
rename to features/sharding/distsql/handler/src/test/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
diff --git a/infra/algorithm/key-generator/core/pom.xml b/infra/algorithm/key-generator/core/pom.xml
new file mode 100644
index 0000000000000..5128f2bdafa5f
--- /dev/null
+++ b/infra/algorithm/key-generator/core/pom.xml
@@ -0,0 +1,43 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.shardingsphere
+ shardingsphere-infra-key-generator
+ 5.4.2-SNAPSHOT
+
+ shardingsphere-infra-key-generator-core
+ ${project.artifactId}
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-infra-common
+ ${project.version}
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-test-util
+ ${project.version}
+ test
+
+
+
diff --git a/features/sharding/api/src/main/java/org/apache/shardingsphere/sharding/spi/KeyGenerateAlgorithm.java b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/algorithm/KeyGenerateAlgorithm.java
similarity index 95%
rename from features/sharding/api/src/main/java/org/apache/shardingsphere/sharding/spi/KeyGenerateAlgorithm.java
rename to infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/algorithm/KeyGenerateAlgorithm.java
index 8b147fa5c35f2..638636a960bfd 100644
--- a/features/sharding/api/src/main/java/org/apache/shardingsphere/sharding/spi/KeyGenerateAlgorithm.java
+++ b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/algorithm/KeyGenerateAlgorithm.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.spi;
+package org.apache.shardingsphere.keygen.core.algorithm;
import org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithm;
diff --git a/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/KeyGenerateSQLException.java b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/KeyGenerateSQLException.java
new file mode 100644
index 0000000000000..ab7a70f033b5b
--- /dev/null
+++ b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/KeyGenerateSQLException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.keygen.core.exception;
+
+import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.SQLState;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.feature.FeatureSQLException;
+
+/**
+ * Key generate SQL exception.
+ */
+public abstract class KeyGenerateSQLException extends FeatureSQLException {
+
+ private static final int FEATURE_CODE = 11;
+
+ private static final long serialVersionUID = 3124409584064186239L;
+
+ protected KeyGenerateSQLException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArgs) {
+ super(sqlState, FEATURE_CODE, errorCode, reason, messageArgs);
+ }
+}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/GenerateKeyStrategyNotFoundException.java b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/algorithm/GenerateKeyStrategyNotFoundException.java
similarity index 88%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/GenerateKeyStrategyNotFoundException.java
rename to infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/algorithm/GenerateKeyStrategyNotFoundException.java
index d0c30a9ac9c68..2fb7b0634ff94 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/GenerateKeyStrategyNotFoundException.java
+++ b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/algorithm/GenerateKeyStrategyNotFoundException.java
@@ -15,15 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.exception.algorithm.keygen;
+package org.apache.shardingsphere.keygen.core.exception.algorithm;
import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
+import org.apache.shardingsphere.keygen.core.exception.KeyGenerateSQLException;
/**
* Generate key strategy not found exception.
*/
-public final class GenerateKeyStrategyNotFoundException extends ShardingSQLException {
+public final class GenerateKeyStrategyNotFoundException extends KeyGenerateSQLException {
private static final long serialVersionUID = 7456922260524630374L;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/KeyGenerateAlgorithmInitializationException.java b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/algorithm/KeyGenerateAlgorithmInitializationException.java
similarity index 83%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/KeyGenerateAlgorithmInitializationException.java
rename to infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/algorithm/KeyGenerateAlgorithmInitializationException.java
index b585a8e1a41d8..df32efacacdab 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/KeyGenerateAlgorithmInitializationException.java
+++ b/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/exception/algorithm/KeyGenerateAlgorithmInitializationException.java
@@ -15,17 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.exception.algorithm.keygen;
+package org.apache.shardingsphere.keygen.core.exception.algorithm;
import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
+import org.apache.shardingsphere.keygen.core.exception.KeyGenerateSQLException;
/**
* Key generate algorithm initialization exception.
*/
-public final class KeyGenerateAlgorithmInitializationException extends ShardingSQLException {
+public final class KeyGenerateAlgorithmInitializationException extends KeyGenerateSQLException {
- private static final long serialVersionUID = -9046956561006694072L;
+ private static final long serialVersionUID = 4137100879778822323L;
public KeyGenerateAlgorithmInitializationException(final String keyGenerateType, final String reason) {
super(XOpenSQLState.GENERAL_ERROR, 91, "Key generate algorithm `%s` initialization failed, reason is: %s.", keyGenerateType, reason);
diff --git a/infra/algorithm/key-generator/pom.xml b/infra/algorithm/key-generator/pom.xml
new file mode 100644
index 0000000000000..d737f6fdffb8a
--- /dev/null
+++ b/infra/algorithm/key-generator/pom.xml
@@ -0,0 +1,34 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.shardingsphere
+ shardingsphere-infra-algorithm
+ 5.4.2-SNAPSHOT
+
+ shardingsphere-infra-key-generator
+ pom
+ ${project.artifactId}
+
+
+ core
+ type
+
+
diff --git a/infra/algorithm/key-generator/type/pom.xml b/infra/algorithm/key-generator/type/pom.xml
new file mode 100644
index 0000000000000..47c37fc365b35
--- /dev/null
+++ b/infra/algorithm/key-generator/type/pom.xml
@@ -0,0 +1,34 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.shardingsphere
+ shardingsphere-infra-key-generator
+ 5.4.2-SNAPSHOT
+
+ shardingsphere-infra-key-generator-type
+ pom
+ ${project.artifactId}
+
+
+ snowflake
+ uuid
+
+
diff --git a/infra/algorithm/key-generator/type/snowflake/pom.xml b/infra/algorithm/key-generator/type/snowflake/pom.xml
new file mode 100644
index 0000000000000..74a8b23ead459
--- /dev/null
+++ b/infra/algorithm/key-generator/type/snowflake/pom.xml
@@ -0,0 +1,52 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.shardingsphere
+ shardingsphere-infra-key-generator-type
+ 5.4.2-SNAPSHOT
+
+ shardingsphere-infra-key-generator-snowflake
+ ${project.artifactId}
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-infra-common
+ ${project.version}
+
+
+ org.apache.shardingsphere
+ shardingsphere-infra-key-generator-core
+ ${project.version}
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-test-util
+ ${project.version}
+ test
+
+
+ org.awaitility
+ awaitility
+
+
+
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java b/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/algorithm/SnowflakeKeyGenerateAlgorithm.java
similarity index 95%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
rename to infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/algorithm/SnowflakeKeyGenerateAlgorithm.java
index 0d5e4a2b2d5e5..95fe29dcca276 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
+++ b/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/algorithm/SnowflakeKeyGenerateAlgorithm.java
@@ -15,16 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.algorithm.keygen;
+package org.apache.shardingsphere.keygen.snowflake.algorithm;
import lombok.Setter;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.instance.InstanceContextAware;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.sharding.exception.algorithm.keygen.KeyGenerateAlgorithmInitializationException;
-import org.apache.shardingsphere.sharding.exception.algorithm.keygen.SnowflakeClockMoveBackException;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.core.exception.algorithm.KeyGenerateAlgorithmInitializationException;
+import org.apache.shardingsphere.keygen.snowflake.exception.SnowflakeClockMoveBackException;
import java.time.Instant;
import java.time.LocalDateTime;
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/TimeService.java b/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/algorithm/TimeService.java
similarity index 94%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/TimeService.java
rename to infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/algorithm/TimeService.java
index a2dcbf490197b..5468a8ac456a1 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/TimeService.java
+++ b/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/algorithm/TimeService.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.algorithm.keygen;
+package org.apache.shardingsphere.keygen.snowflake.algorithm;
/**
* Time service.
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/SnowflakeClockMoveBackException.java b/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/exception/SnowflakeClockMoveBackException.java
similarity index 80%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/SnowflakeClockMoveBackException.java
rename to infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/exception/SnowflakeClockMoveBackException.java
index ca5adbaa68da3..823a0e359d2f2 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/algorithm/keygen/SnowflakeClockMoveBackException.java
+++ b/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/exception/SnowflakeClockMoveBackException.java
@@ -15,17 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.exception.algorithm.keygen;
+package org.apache.shardingsphere.keygen.snowflake.exception;
import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
+import org.apache.shardingsphere.keygen.core.exception.KeyGenerateSQLException;
/**
* Snowflake clock move back exception.
*/
-public final class SnowflakeClockMoveBackException extends ShardingSQLException {
+public final class SnowflakeClockMoveBackException extends KeyGenerateSQLException {
- private static final long serialVersionUID = -2435731376659956566L;
+ private static final long serialVersionUID = 3076059285632288623L;
public SnowflakeClockMoveBackException(final long lastMillis, final long currentMillis) {
super(XOpenSQLState.GENERAL_ERROR, 92, "Clock is moving backwards, last time is %d milliseconds, current time is %d milliseconds.", lastMillis, currentMillis);
diff --git a/features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm b/infra/algorithm/key-generator/type/snowflake/src/main/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
similarity index 83%
rename from features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
rename to infra/algorithm/key-generator/type/snowflake/src/main/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
index 3ce4e58b0d48a..e61918401f509 100644
--- a/features/sharding/core/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
+++ b/infra/algorithm/key-generator/type/snowflake/src/main/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
@@ -15,5 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm
-org.apache.shardingsphere.sharding.algorithm.keygen.UUIDKeyGenerateAlgorithm
+org.apache.shardingsphere.keygen.snowflake.algorithm.SnowflakeKeyGenerateAlgorithm
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java b/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/algorithm/SnowflakeKeyGenerateAlgorithmTest.java
similarity index 96%
rename from features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
rename to infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/algorithm/SnowflakeKeyGenerateAlgorithmTest.java
index 95bae0f3de111..d5ff80bed737f 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
+++ b/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/algorithm/SnowflakeKeyGenerateAlgorithmTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.algorithm.keygen;
+package org.apache.shardingsphere.keygen.snowflake.algorithm;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
@@ -25,13 +25,13 @@
import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.mode.ModeContextManager;
import org.apache.shardingsphere.infra.lock.LockContext;
-import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.sharding.algorithm.keygen.fixture.FixedTimeService;
-import org.apache.shardingsphere.sharding.algorithm.keygen.fixture.WorkerIdGeneratorFixture;
-import org.apache.shardingsphere.sharding.exception.algorithm.keygen.KeyGenerateAlgorithmInitializationException;
-import org.apache.shardingsphere.sharding.exception.algorithm.keygen.SnowflakeClockMoveBackException;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
+import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.core.exception.algorithm.KeyGenerateAlgorithmInitializationException;
+import org.apache.shardingsphere.keygen.snowflake.exception.SnowflakeClockMoveBackException;
+import org.apache.shardingsphere.keygen.snowflake.fixture.FixedTimeService;
+import org.apache.shardingsphere.keygen.snowflake.fixture.WorkerIdGeneratorFixture;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.awaitility.Awaitility;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/FixedTimeService.java b/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/fixture/FixedTimeService.java
similarity index 85%
rename from features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/FixedTimeService.java
rename to infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/fixture/FixedTimeService.java
index 0546c9c688038..990e46436298c 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/FixedTimeService.java
+++ b/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/fixture/FixedTimeService.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.algorithm.keygen.fixture;
+package org.apache.shardingsphere.keygen.snowflake.fixture;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
-import org.apache.shardingsphere.sharding.algorithm.keygen.TimeService;
+import org.apache.shardingsphere.keygen.snowflake.algorithm.SnowflakeKeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.snowflake.algorithm.TimeService;
import java.util.concurrent.atomic.AtomicInteger;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/WorkerIdGeneratorFixture.java b/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/fixture/WorkerIdGeneratorFixture.java
similarity index 95%
rename from features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/WorkerIdGeneratorFixture.java
rename to infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/fixture/WorkerIdGeneratorFixture.java
index 10218a80bb40c..88628abb557b6 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/fixture/WorkerIdGeneratorFixture.java
+++ b/infra/algorithm/key-generator/type/snowflake/src/test/java/org/apache/shardingsphere/keygen/snowflake/fixture/WorkerIdGeneratorFixture.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.algorithm.keygen.fixture;
+package org.apache.shardingsphere.keygen.snowflake.fixture;
import com.google.common.base.Preconditions;
import lombok.RequiredArgsConstructor;
diff --git a/infra/algorithm/key-generator/type/uuid/pom.xml b/infra/algorithm/key-generator/type/uuid/pom.xml
new file mode 100644
index 0000000000000..cdeef599b3351
--- /dev/null
+++ b/infra/algorithm/key-generator/type/uuid/pom.xml
@@ -0,0 +1,52 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.shardingsphere
+ shardingsphere-infra-key-generator-type
+ 5.4.2-SNAPSHOT
+
+ shardingsphere-infra-key-generator-uuid
+ ${project.artifactId}
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-infra-common
+ ${project.version}
+
+
+ org.apache.shardingsphere
+ shardingsphere-infra-key-generator-core
+ ${project.version}
+
+
+
+ org.apache.shardingsphere
+ shardingsphere-test-util
+ ${project.version}
+ test
+
+
+ org.awaitility
+ awaitility
+
+
+
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java b/infra/algorithm/key-generator/type/uuid/src/main/java/org/apache/shardingsphere/keygen/uuid/algorithm/UUIDKeyGenerateAlgorithm.java
similarity index 90%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java
rename to infra/algorithm/key-generator/type/uuid/src/main/java/org/apache/shardingsphere/keygen/uuid/algorithm/UUIDKeyGenerateAlgorithm.java
index b9b96b4ae5018..01cfa43b9c4d1 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java
+++ b/infra/algorithm/key-generator/type/uuid/src/main/java/org/apache/shardingsphere/keygen/uuid/algorithm/UUIDKeyGenerateAlgorithm.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.algorithm.keygen;
+package org.apache.shardingsphere.keygen.uuid.algorithm;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
diff --git a/infra/algorithm/key-generator/type/uuid/src/main/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm b/infra/algorithm/key-generator/type/uuid/src/main/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
new file mode 100644
index 0000000000000..ce91df42f290f
--- /dev/null
+++ b/infra/algorithm/key-generator/type/uuid/src/main/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.keygen.uuid.algorithm.UUIDKeyGenerateAlgorithm
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithmTest.java b/infra/algorithm/key-generator/type/uuid/src/test/java/org/apache/shardingsphere/keygen/uuid/algorithm/UUIDKeyGenerateAlgorithmTest.java
similarity index 95%
rename from features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithmTest.java
rename to infra/algorithm/key-generator/type/uuid/src/test/java/org/apache/shardingsphere/keygen/uuid/algorithm/UUIDKeyGenerateAlgorithmTest.java
index 9cde0bc22e2b4..b8c65e0eff7e0 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithmTest.java
+++ b/infra/algorithm/key-generator/type/uuid/src/test/java/org/apache/shardingsphere/keygen/uuid/algorithm/UUIDKeyGenerateAlgorithmTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.algorithm.keygen;
+package org.apache.shardingsphere.keygen.uuid.algorithm;
import org.junit.jupiter.api.Test;
diff --git a/infra/algorithm/pom.xml b/infra/algorithm/pom.xml
new file mode 100644
index 0000000000000..50db5cd9cd974
--- /dev/null
+++ b/infra/algorithm/pom.xml
@@ -0,0 +1,33 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.shardingsphere
+ shardingsphere-infra
+ 5.4.2-SNAPSHOT
+
+ shardingsphere-infra-algorithm
+ pom
+ ${project.artifactId}
+
+
+ key-generator
+
+
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java
index b795f47860316..bc3fc0a88f532 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java
@@ -21,6 +21,8 @@
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.util.json.JsonUtils;
+import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Properties;
/**
@@ -36,6 +38,8 @@ public final class PropertiesConverter {
* @return converted string content
*/
public static String convert(final Properties props) {
- return JsonUtils.toJsonString(props);
+ Map