未验证 提交 1708dbd4 编写于 作者: L Liang Zhang 提交者: GitHub

Add ShardingSphereAlgorithmConfiguration to abstract algorithm configuration (#6034)

* remove ShardingAlgorithmConfiguration

* remove KeyGenerateAlgorithmConfiguration

* remove LoadBalanceAlgorithmConfiguration

* remove EncryptAlgorithmConfiguration

* for checkstyle
上级 d7ac54f9
......@@ -20,11 +20,11 @@ package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import com.google.common.collect.ImmutableMap;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.orchestration.center.config.CenterConfiguration;
import org.apache.shardingsphere.orchestration.center.config.OrchestrationConfiguration;
......@@ -61,9 +61,9 @@ public final class LocalEncryptConfiguration implements ExampleConfiguration {
return new EncryptTableRuleConfiguration("t_order", Collections.singleton(encryptColumnRuleConfiguration));
}
private EncryptAlgorithmConfiguration createEncryptAlgorithmConfiguration() {
private ShardingSphereAlgorithmConfiguration createEncryptAlgorithmConfiguration() {
Properties props = new Properties();
props.setProperty("aes.key.value", "123456");
return new EncryptAlgorithmConfiguration("AES", props);
return new ShardingSphereAlgorithmConfiguration("AES", props);
}
}
......@@ -20,11 +20,10 @@ package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.orchestration.center.config.CenterConfiguration;
import org.apache.shardingsphere.orchestration.center.config.OrchestrationConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -64,9 +63,9 @@ public final class LocalShardingDatabasesAndTablesConfiguration implements Examp
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
Properties props = new Properties();
props.setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
result.getShardingAlgorithms() .put("inline", new ShardingAlgorithmConfiguration("INLINE", props));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -20,11 +20,10 @@ package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.orchestration.center.config.CenterConfiguration;
import org.apache.shardingsphere.orchestration.center.config.OrchestrationConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -63,8 +62,8 @@ public final class LocalShardingDatabasesConfiguration implements ExampleConfigu
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "inline"));
Properties props = new Properties();
props.setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
result.getShardingAlgorithms() .put("inline", new ShardingAlgorithmConfiguration("INLINE", props));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProps()));
result.getShardingAlgorithms() .put("inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProps()));
return result;
}
......
......@@ -21,13 +21,12 @@ import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingS
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import org.apache.shardingsphere.orchestration.center.config.CenterConfiguration;
import org.apache.shardingsphere.orchestration.center.config.OrchestrationConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -67,9 +66,9 @@ public final class LocalShardingMasterSlaveConfiguration implements ExampleConfi
result.getBroadcastTables().add("t_address");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "standard_test_db"));
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -20,11 +20,10 @@ package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import org.apache.shardingsphere.driver.orchestration.api.OrchestrationShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.orchestration.center.config.CenterConfiguration;
import org.apache.shardingsphere.orchestration.center.config.OrchestrationConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -57,8 +56,8 @@ public final class LocalShardingTablesConfiguration implements ExampleConfigurat
result.getBindingTableGroups().add("t_order, t_order_item");
result.getBroadcastTables().add("t_address");
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -19,11 +19,11 @@ package org.apache.shardingsphere.example.encrypt.table.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import javax.sql.DataSource;
import java.sql.SQLException;
......@@ -43,9 +43,9 @@ public final class EncryptDatabasesConfiguration implements ExampleConfiguration
EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("user_name", "user_name", "", "user_name_plain", "name_encryptor");
EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("pwd", "pwd", "assisted_query_pwd", "", "pwd_encryptor");
EncryptTableRuleConfiguration encryptTableRuleConfiguration = new EncryptTableRuleConfiguration("t_user", Arrays.asList(columnConfigAes, columnConfigTest));
Map<String, EncryptAlgorithmConfiguration> encryptAlgorithmConfigurations = new LinkedHashMap<>(2, 1);
encryptAlgorithmConfigurations.put("name_encryptor", new EncryptAlgorithmConfiguration("AES", props));
encryptAlgorithmConfigurations.put("pwd_encryptor", new EncryptAlgorithmConfiguration("assistedTest", props));
Map<String, ShardingSphereAlgorithmConfiguration> encryptAlgorithmConfigurations = new LinkedHashMap<>(2, 1);
encryptAlgorithmConfigurations.put("name_encryptor", new ShardingSphereAlgorithmConfiguration("AES", props));
encryptAlgorithmConfigurations.put("pwd_encryptor", new ShardingSphereAlgorithmConfiguration("assistedTest", props));
EncryptRuleConfiguration encryptRuleConfiguration = new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfiguration), encryptAlgorithmConfigurations);
try {
return ShardingSphereDataSourceFactory.createDataSource(DataSourceUtil.createDataSource("demo_ds"), Collections.singleton(encryptRuleConfiguration), props);
......
......@@ -21,9 +21,9 @@ import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import javax.sql.DataSource;
......@@ -61,12 +61,12 @@ public final class EncryptShadowDatabasesConfiguration implements ExampleConfigu
return result;
}
private Map<String, EncryptAlgorithmConfiguration> getEncryptAlgorithmConfigurations() {
Map<String, EncryptAlgorithmConfiguration> result = new LinkedHashMap<>(2, 1);
private Map<String, ShardingSphereAlgorithmConfiguration> getEncryptAlgorithmConfigurations() {
Map<String, ShardingSphereAlgorithmConfiguration> result = new LinkedHashMap<>(2, 1);
Properties props = new Properties();
props.setProperty("aes.key.value", "123456");
result.put("name_encryptor", new EncryptAlgorithmConfiguration("AES", props));
result.put("pwd_encryptor", new EncryptAlgorithmConfiguration("assistedTest", null));
result.put("name_encryptor", new ShardingSphereAlgorithmConfiguration("AES", props));
result.put("pwd_encryptor", new ShardingSphereAlgorithmConfiguration("assistedTest", null));
return result;
}
}
......@@ -20,9 +20,9 @@ package org.apache.shardingsphere.example.shadow.table.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.strategy.algorithm.sharding.inline.InlineShardingAlgorithm;
......@@ -50,10 +50,10 @@ public final class ShardingShadowDatabasesConfiguration implements ExampleConfig
shardingRuleConfiguration.getTables().add(getUserTableConfiguration());
Properties props = new Properties();
props.setProperty("algorithm.expression", "ds_${user_id % 2}");
shardingRuleConfiguration.getShardingAlgorithms() .put("database_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfiguration.getShardingAlgorithms() .put("database_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_user");
shardingRuleConfiguration.getShardingAlgorithms() .put("table_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfiguration.getShardingAlgorithms() .put("table_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props.setProperty("sql.show", "true");
ShadowRuleConfiguration shadowRuleConfiguration = new ShadowRuleConfiguration("shadow", shadowMappings);
return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Arrays.asList(shadowRuleConfiguration, shardingRuleConfiguration), props);
......
......@@ -20,9 +20,8 @@ package org.apache.shardingsphere.example.sharding.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -51,9 +50,9 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
Properties props = new Properties();
props.setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
result.getShardingAlgorithms() .put("inline", new ShardingAlgorithmConfiguration("INLINE", props));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -20,9 +20,8 @@ package org.apache.shardingsphere.example.sharding.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -49,9 +48,9 @@ public final class ShardingDatabasesAndTablesConfigurationRange implements Examp
result.getBroadcastTables().add("t_address");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "standard_test_db"));
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -20,9 +20,8 @@ package org.apache.shardingsphere.example.sharding.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -49,8 +48,8 @@ public final class ShardingDatabasesConfigurationPrecise implements ExampleConfi
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "inline"));
Properties props = new Properties();
props.setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
result.getShardingAlgorithms() .put("inline", new ShardingAlgorithmConfiguration("INLINE", props));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -21,9 +21,8 @@ import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -52,8 +51,8 @@ public final class ShardingDatabasesConfigurationRange implements ExampleConfigu
result.getTables().add(getOrderItemTableRuleConfiguration());
result.getBroadcastTables().add("t_address");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "standard_test_db"));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -20,11 +20,10 @@ package org.apache.shardingsphere.example.sharding.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -63,9 +62,9 @@ public final class ShardingMasterSlaveConfigurationPrecise implements ExampleCon
result.getBroadcastTables().add("t_address");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "standard_test_db"));
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -20,11 +20,10 @@ package org.apache.shardingsphere.example.sharding.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -63,9 +62,9 @@ public final class ShardingMasterSlaveConfigurationRange implements ExampleConfi
result.getBroadcastTables().add("t_address");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "standard_test_db"));
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("standard_test_db", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_DB", new Properties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -20,9 +20,8 @@ package org.apache.shardingsphere.example.sharding.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -48,8 +47,8 @@ public final class ShardingTablesConfigurationPrecise implements ExampleConfigur
result.getBindingTableGroups().add("t_order, t_order_item");
result.getBroadcastTables().add("t_address");
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -20,9 +20,8 @@ package org.apache.shardingsphere.example.sharding.raw.jdbc.config;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
......@@ -48,8 +47,8 @@ public final class ShardingTablesConfigurationRange implements ExampleConfigurat
result.getBindingTableGroups().add("t_order, t_order_item");
result.getBroadcastTables().add("t_address");
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "standard_test_tbl"));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getShardingAlgorithms() .put("standard_test_tbl", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST_TBL", new Properties()));
result.getKeyGenerators().put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
}
......
......@@ -19,22 +19,22 @@ package org.apache.shardingsphere.orchestration.core.configcenter;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
import org.apache.shardingsphere.orchestration.center.ConfigCenterRepository;
import org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
import org.apache.shardingsphere.orchestration.center.ConfigCenterRepository;
import org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -474,7 +474,7 @@ public final class ConfigCenterTest {
} else if (each instanceof EncryptRuleConfiguration) {
EncryptRuleConfiguration encryptRuleConfiguration = (EncryptRuleConfiguration) each;
assertThat(encryptRuleConfiguration.getEncryptors().size(), is(2));
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = encryptRuleConfiguration.getEncryptors().get("aes_encryptor");
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = encryptRuleConfiguration.getEncryptors().get("aes_encryptor");
assertThat(encryptAlgorithmConfiguration.getType(), is("AES"));
assertThat(encryptAlgorithmConfiguration.getProps().get("aes.key.value").toString(), is("123456abcd"));
}
......@@ -509,7 +509,7 @@ public final class ConfigCenterTest {
ConfigCenter configurationService = new ConfigCenter("test", configCenterRepository);
EncryptRuleConfiguration actual = (EncryptRuleConfiguration) configurationService.loadRuleConfigurations("sharding_db").iterator().next();
assertThat(actual.getEncryptors().size(), is(1));
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = actual.getEncryptors().get("order_encryptor");
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = actual.getEncryptors().get("order_encryptor");
assertThat(encryptAlgorithmConfiguration.getType(), is("AES"));
assertThat(encryptAlgorithmConfiguration.getProps().get("aes.key.value").toString(), is("123456"));
}
......
......@@ -19,8 +19,8 @@ package org.apache.shardingsphere.orchestration.core.configcenter.listener;
import lombok.SneakyThrows;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.orchestration.center.ConfigCenterRepository;
import org.apache.shardingsphere.orchestration.center.listener.DataChangedEvent;
......@@ -123,7 +123,7 @@ public final class SchemaChangedListenerTest {
assertThat(event.getRuleConfigurations().iterator().next(), instanceOf(EncryptRuleConfiguration.class));
EncryptRuleConfiguration encryptRuleConfiguration = (EncryptRuleConfiguration) event.getRuleConfigurations().iterator().next();
assertThat(encryptRuleConfiguration.getEncryptors().size(), is(1));
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = encryptRuleConfiguration.getEncryptors().get("order_encryptor");
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = encryptRuleConfiguration.getEncryptors().get("order_encryptor");
assertThat(encryptAlgorithmConfiguration.getType(), is("AES"));
assertThat(encryptAlgorithmConfiguration.getProps().get("aes.key.value").toString(), is("123456"));
}
......
......@@ -19,9 +19,9 @@ package org.apache.shardingsphere.encrypt.api.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import java.util.Collection;
import java.util.Map;
......@@ -35,5 +35,5 @@ public final class EncryptRuleConfiguration implements RuleConfiguration {
private final Collection<EncryptTableRuleConfiguration> tables;
private final Map<String, EncryptAlgorithmConfiguration> encryptors;
private final Map<String, ShardingSphereAlgorithmConfiguration> encryptors;
}
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.encrypt.api.config;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.junit.Test;
import java.util.Properties;
......@@ -29,12 +29,12 @@ public final class EncryptAlgorithmConfigurationTest {
@Test(expected = IllegalArgumentException.class)
public void assertConstructorWithoutType() {
new EncryptAlgorithmConfiguration(null, new Properties());
new ShardingSphereAlgorithmConfiguration(null, new Properties());
}
@Test
public void assertConstructorWithoutProperties() {
EncryptAlgorithmConfiguration actual = new EncryptAlgorithmConfiguration("TEST", new Properties());
ShardingSphereAlgorithmConfiguration actual = new ShardingSphereAlgorithmConfiguration("TEST", new Properties());
assertThat(actual.getType(), is("TEST"));
assertThat(actual.getProps(), is(new Properties()));
}
......@@ -43,7 +43,7 @@ public final class EncryptAlgorithmConfigurationTest {
public void assertConstructorWithProperties() {
Properties props = new Properties();
props.setProperty("key", "value");
EncryptAlgorithmConfiguration actual = new EncryptAlgorithmConfiguration("TEST", props);
ShardingSphereAlgorithmConfiguration actual = new ShardingSphereAlgorithmConfiguration("TEST", props);
assertThat(actual.getType(), is("TEST"));
assertThat(actual.getProps(), is(props));
}
......
......@@ -18,13 +18,13 @@
package org.apache.shardingsphere.encrypt.yaml.swapper;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.constant.EncryptOrder;
import org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.yaml.swapper.algorithm.EncryptAlgorithmConfigurationYamlSwapper;
import org.apache.shardingsphere.encrypt.yaml.swapper.rule.EncryptTableRuleConfigurationYamlSwapper;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper;
......@@ -66,8 +66,8 @@ public final class EncryptRuleConfigurationYamlSwapper implements YamlRuleConfig
return result;
}
private Map<String, EncryptAlgorithmConfiguration> swapEncryptAlgorithm(final YamlEncryptRuleConfiguration yamlConfiguration) {
Map<String, EncryptAlgorithmConfiguration> result = new LinkedHashMap<>();
private Map<String, ShardingSphereAlgorithmConfiguration> swapEncryptAlgorithm(final YamlEncryptRuleConfiguration yamlConfiguration) {
Map<String, ShardingSphereAlgorithmConfiguration> result = new LinkedHashMap<>();
for (Entry<String, YamlShardingSphereAlgorithmConfiguration> entry : yamlConfiguration.getEncryptors().entrySet()) {
YamlShardingSphereAlgorithmConfiguration yamlEncryptAlgorithmConfiguration = entry.getValue();
result.put(entry.getKey(), encryptAlgorithmConfigurationYamlSwapper.swap(yamlEncryptAlgorithmConfiguration));
......
......@@ -17,17 +17,17 @@
package org.apache.shardingsphere.encrypt.yaml.swapper.algorithm;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
/**
* Encrypt algorithm configuration YAML swapper.
*/
public final class EncryptAlgorithmConfigurationYamlSwapper implements YamlSwapper<YamlShardingSphereAlgorithmConfiguration, EncryptAlgorithmConfiguration> {
public final class EncryptAlgorithmConfigurationYamlSwapper implements YamlSwapper<YamlShardingSphereAlgorithmConfiguration, ShardingSphereAlgorithmConfiguration> {
@Override
public YamlShardingSphereAlgorithmConfiguration swap(final EncryptAlgorithmConfiguration data) {
public YamlShardingSphereAlgorithmConfiguration swap(final ShardingSphereAlgorithmConfiguration data) {
YamlShardingSphereAlgorithmConfiguration result = new YamlShardingSphereAlgorithmConfiguration();
result.setType(data.getType());
result.setProps(data.getProps());
......@@ -35,7 +35,7 @@ public final class EncryptAlgorithmConfigurationYamlSwapper implements YamlSwapp
}
@Override
public EncryptAlgorithmConfiguration swap(final YamlShardingSphereAlgorithmConfiguration yamlConfiguration) {
return new EncryptAlgorithmConfiguration(yamlConfiguration.getType(), yamlConfiguration.getProps());
public ShardingSphereAlgorithmConfiguration swap(final YamlShardingSphereAlgorithmConfiguration yamlConfiguration) {
return new ShardingSphereAlgorithmConfiguration(yamlConfiguration.getType(), yamlConfiguration.getProps());
}
}
......@@ -20,9 +20,9 @@ package org.apache.shardingsphere.encrypt.log;
import com.google.common.collect.ImmutableMap;
import lombok.SneakyThrows;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.log.ConfigurationLogger;
import org.junit.Before;
import org.junit.Test;
......@@ -86,7 +86,7 @@ public final class EncryptConfigurationLoggerTest {
private EncryptRuleConfiguration getEncryptConfiguration() {
Properties props = new Properties();
props.put("aes.key.value", "123456abc");
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = new EncryptAlgorithmConfiguration("AES", props);
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = new ShardingSphereAlgorithmConfiguration("AES", props);
EncryptTableRuleConfiguration encryptTableRuleConfiguration = new EncryptTableRuleConfiguration(
"t_encrypt", Collections.singleton(new EncryptColumnRuleConfiguration("user_id", "user_encrypt", "user_assisted", "user_decrypt", "aes_encryptor")));
return new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfiguration), ImmutableMap.of("aes_encryptor", encryptAlgorithmConfiguration));
......
......@@ -19,9 +19,9 @@ package org.apache.shardingsphere.encrypt.rule;
import com.google.common.collect.ImmutableMap;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.junit.Before;
import org.junit.Test;
......@@ -51,7 +51,7 @@ public final class EncryptRuleTest {
Properties props = new Properties();
EncryptColumnRuleConfiguration columnConfig = new EncryptColumnRuleConfiguration(column, "cipher_pwd", "", "plain_pwd", "aes");
EncryptColumnRuleConfiguration idNumberConfig = new EncryptColumnRuleConfiguration(idNumber, "cipher_id_number", "", "plain_id_number", "aes");
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = new EncryptAlgorithmConfiguration("assistedTest", props);
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = new ShardingSphereAlgorithmConfiguration("assistedTest", props);
EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration(table, Arrays.asList(columnConfig, idNumberConfig));
encryptRuleConfig = new EncryptRuleConfiguration(Collections.singleton(tableConfig), ImmutableMap.of("aes", encryptAlgorithmConfiguration));
}
......
......@@ -20,7 +20,7 @@ package org.apache.shardingsphere.masterslave.api.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.algorithm.LoadBalanceAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import java.util.Collection;
......@@ -35,5 +35,5 @@ public final class MasterSlaveRuleConfiguration implements RuleConfiguration {
private final Collection<MasterSlaveDataSourceRuleConfiguration> dataSources;
private final Map<String, LoadBalanceAlgorithmConfiguration> loadBalancers;
private final Map<String, ShardingSphereAlgorithmConfiguration> loadBalancers;
}
/*
* 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.masterslave.api.config.algorithm;
import org.apache.shardingsphere.infra.config.TypedSPIConfiguration;
import java.util.Properties;
/**
* Master-slave load balance algorithm configuration.
*/
public final class LoadBalanceAlgorithmConfiguration extends TypedSPIConfiguration {
public LoadBalanceAlgorithmConfiguration(final String type, final Properties props) {
super(type, props);
}
}
......@@ -17,10 +17,10 @@
package org.apache.shardingsphere.masterslave.yaml.swapper;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.algorithm.LoadBalanceAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import org.apache.shardingsphere.masterslave.constant.MasterSlaveOrder;
import org.apache.shardingsphere.masterslave.yaml.config.YamlMasterSlaveRuleConfiguration;
......@@ -60,7 +60,7 @@ public final class MasterSlaveRuleConfigurationYamlSwapper implements YamlRuleCo
for (Entry<String, YamlMasterSlaveDataSourceRuleConfiguration> entry : yamlConfiguration.getDataSources().entrySet()) {
dataSources.add(swap(entry.getKey(), entry.getValue()));
}
Map<String, LoadBalanceAlgorithmConfiguration> loadBalancers = new LinkedHashMap<>(yamlConfiguration.getLoadBalancers().entrySet().size(), 1);
Map<String, ShardingSphereAlgorithmConfiguration> loadBalancers = new LinkedHashMap<>(yamlConfiguration.getLoadBalancers().entrySet().size(), 1);
for (Entry<String, YamlShardingSphereAlgorithmConfiguration> entry : yamlConfiguration.getLoadBalancers().entrySet()) {
loadBalancers.put(entry.getKey(), swap(entry.getValue()));
}
......@@ -72,8 +72,8 @@ public final class MasterSlaveRuleConfigurationYamlSwapper implements YamlRuleCo
yamlDataSourceRuleConfiguration.getMasterDataSourceName(), yamlDataSourceRuleConfiguration.getSlaveDataSourceNames(), yamlDataSourceRuleConfiguration.getLoadBalancerName());
}
private LoadBalanceAlgorithmConfiguration swap(final YamlShardingSphereAlgorithmConfiguration yamlLoadBalanceAlgorithmConfiguration) {
return new LoadBalanceAlgorithmConfiguration(yamlLoadBalanceAlgorithmConfiguration.getType(), yamlLoadBalanceAlgorithmConfiguration.getProps());
private ShardingSphereAlgorithmConfiguration swap(final YamlShardingSphereAlgorithmConfiguration yamlLoadBalanceAlgorithmConfiguration) {
return new ShardingSphereAlgorithmConfiguration(yamlLoadBalanceAlgorithmConfiguration.getType(), yamlLoadBalanceAlgorithmConfiguration.getProps());
}
@Override
......
......@@ -18,9 +18,9 @@
package org.apache.shardingsphere.masterslave.rule;
import com.google.common.collect.ImmutableMap;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.algorithm.LoadBalanceAlgorithmConfiguration;
import org.junit.Test;
import java.util.Arrays;
......@@ -54,7 +54,7 @@ public final class MasterSlaveRuleTest {
private MasterSlaveRule createMasterSlaveRule() {
MasterSlaveDataSourceRuleConfiguration configuration = new MasterSlaveDataSourceRuleConfiguration("test_ms", "master_db", Arrays.asList("slave_db_0", "slave_db_1"), "random");
return new MasterSlaveRule(new MasterSlaveRuleConfiguration(
Collections.singleton(configuration), ImmutableMap.of("random", new LoadBalanceAlgorithmConfiguration("RANDOM", new Properties()))));
Collections.singleton(configuration), ImmutableMap.of("random", new ShardingSphereAlgorithmConfiguration("RANDOM", new Properties()))));
}
private void assertDataSourceRule(final MasterSlaveDataSourceRule actual) {
......
......@@ -18,11 +18,11 @@
package org.apache.shardingsphere.masterslave.yaml.swapper;
import com.google.common.collect.ImmutableMap;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.algorithm.LoadBalanceAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import org.apache.shardingsphere.masterslave.yaml.config.rule.YamlMasterSlaveDataSourceRuleConfiguration;
import org.apache.shardingsphere.masterslave.yaml.config.YamlMasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.yaml.config.rule.YamlMasterSlaveDataSourceRuleConfiguration;
import org.junit.Test;
import java.util.Arrays;
......@@ -39,7 +39,7 @@ public final class MasterSlaveRuleConfigurationYamlSwapperTest {
public void assertSwapToYamlWithLoadBalanceAlgorithm() {
MasterSlaveDataSourceRuleConfiguration dataSourceConfiguration = new MasterSlaveDataSourceRuleConfiguration("ds", "master", Collections.singletonList("slave"), "roundRobin");
YamlMasterSlaveRuleConfiguration actual = new MasterSlaveRuleConfigurationYamlSwapper().swap(new MasterSlaveRuleConfiguration(
Collections.singleton(dataSourceConfiguration), ImmutableMap.of("roundRobin", new LoadBalanceAlgorithmConfiguration("ROUND_ROBIN", new Properties()))));
Collections.singleton(dataSourceConfiguration), ImmutableMap.of("roundRobin", new ShardingSphereAlgorithmConfiguration("ROUND_ROBIN", new Properties()))));
assertThat(actual.getDataSources().get("ds").getName(), is("ds"));
assertThat(actual.getDataSources().get("ds").getMasterDataSourceName(), is("master"));
assertThat(actual.getDataSources().get("ds").getSlaveDataSourceNames(), is(Collections.singletonList("slave")));
......
......@@ -20,8 +20,7 @@ package org.apache.shardingsphere.sharding.api.config;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
......@@ -53,7 +52,7 @@ public final class ShardingRuleConfiguration implements RuleConfiguration {
private KeyGenerateStrategyConfiguration defaultKeyGenerateStrategy;
private Map<String, ShardingAlgorithmConfiguration> shardingAlgorithms = new LinkedHashMap<>();
private Map<String, ShardingSphereAlgorithmConfiguration> shardingAlgorithms = new LinkedHashMap<>();
private Map<String, KeyGenerateAlgorithmConfiguration> keyGenerators = new LinkedHashMap<>();
private Map<String, ShardingSphereAlgorithmConfiguration> keyGenerators = new LinkedHashMap<>();
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.shardingsphere.sharding.api.config.algorithm;
import org.apache.shardingsphere.infra.config.TypedSPIConfiguration;
import java.util.Properties;
/**
* Key generate algorithm configuration.
*/
public final class KeyGenerateAlgorithmConfiguration extends TypedSPIConfiguration {
public KeyGenerateAlgorithmConfiguration(final String type, final Properties props) {
super(type, props);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.shardingsphere.sharding.api.config.algorithm;
import org.apache.shardingsphere.infra.config.TypedSPIConfiguration;
import java.util.Properties;
/**
* Sharding algorithm configuration.
*/
public final class ShardingAlgorithmConfiguration extends TypedSPIConfiguration {
public ShardingAlgorithmConfiguration(final String type, final Properties props) {
super(type, props);
}
}
......@@ -17,23 +17,23 @@
package org.apache.shardingsphere.sharding.yaml.swapper.algorithm;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
/**
* Key generate algorithm configuration YAML swapper.
*/
public final class KeyGenerateAlgorithmConfigurationYamlSwapper implements YamlSwapper<YamlShardingSphereAlgorithmConfiguration, KeyGenerateAlgorithmConfiguration> {
public final class KeyGenerateAlgorithmConfigurationYamlSwapper implements YamlSwapper<YamlShardingSphereAlgorithmConfiguration, ShardingSphereAlgorithmConfiguration> {
static {
ShardingSphereServiceLoader.register(KeyGenerateAlgorithm.class);
}
@Override
public YamlShardingSphereAlgorithmConfiguration swap(final KeyGenerateAlgorithmConfiguration data) {
public YamlShardingSphereAlgorithmConfiguration swap(final ShardingSphereAlgorithmConfiguration data) {
YamlShardingSphereAlgorithmConfiguration result = new YamlShardingSphereAlgorithmConfiguration();
result.setType(data.getType());
result.setProps(data.getProps());
......@@ -41,7 +41,7 @@ public final class KeyGenerateAlgorithmConfigurationYamlSwapper implements YamlS
}
@Override
public KeyGenerateAlgorithmConfiguration swap(final YamlShardingSphereAlgorithmConfiguration yamlConfiguration) {
return new KeyGenerateAlgorithmConfiguration(yamlConfiguration.getType(), yamlConfiguration.getProps());
public ShardingSphereAlgorithmConfiguration swap(final YamlShardingSphereAlgorithmConfiguration yamlConfiguration) {
return new ShardingSphereAlgorithmConfiguration(yamlConfiguration.getType(), yamlConfiguration.getProps());
}
}
......@@ -17,23 +17,23 @@
package org.apache.shardingsphere.sharding.yaml.swapper.algorithm;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
/**
* Sharding algorithm configuration YAML swapper.
*/
public final class ShardingAlgorithmConfigurationYamlSwapper implements YamlSwapper<YamlShardingSphereAlgorithmConfiguration, ShardingAlgorithmConfiguration> {
public final class ShardingAlgorithmConfigurationYamlSwapper implements YamlSwapper<YamlShardingSphereAlgorithmConfiguration, ShardingSphereAlgorithmConfiguration> {
static {
ShardingSphereServiceLoader.register(ShardingAlgorithm.class);
}
@Override
public YamlShardingSphereAlgorithmConfiguration swap(final ShardingAlgorithmConfiguration data) {
public YamlShardingSphereAlgorithmConfiguration swap(final ShardingSphereAlgorithmConfiguration data) {
YamlShardingSphereAlgorithmConfiguration result = new YamlShardingSphereAlgorithmConfiguration();
result.setType(data.getType());
result.setProps(data.getProps());
......@@ -41,7 +41,7 @@ public final class ShardingAlgorithmConfigurationYamlSwapper implements YamlSwap
}
@Override
public ShardingAlgorithmConfiguration swap(final YamlShardingSphereAlgorithmConfiguration yamlConfiguration) {
return new ShardingAlgorithmConfiguration(yamlConfiguration.getType(), yamlConfiguration.getProps());
public ShardingSphereAlgorithmConfiguration swap(final YamlShardingSphereAlgorithmConfiguration yamlConfiguration) {
return new ShardingSphereAlgorithmConfiguration(yamlConfiguration.getType(), yamlConfiguration.getProps());
}
}
......@@ -17,11 +17,10 @@
package org.apache.shardingsphere.sharding.rule;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
......@@ -223,7 +222,7 @@ public final class ShardingRuleTest {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTables().add(createTableRuleConfigWithAllStrategies());
shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("column", "STANDARD_TEST"));
shardingRuleConfig.getShardingAlgorithms().put("standard", new ShardingAlgorithmConfiguration("STANDARD_TEST", new Properties()));
shardingRuleConfig.getShardingAlgorithms().put("standard", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST", new Properties()));
assertTrue(new ShardingRule(shardingRuleConfig, createDataSourceNames()).isShardingColumn("column", "LOGIC_TABLE"));
}
......@@ -232,7 +231,7 @@ public final class ShardingRuleTest {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTables().add(createTableRuleConfigWithAllStrategies());
shardingRuleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("column", "STANDARD_TEST"));
shardingRuleConfig.getShardingAlgorithms().put("standard", new ShardingAlgorithmConfiguration("STANDARD_TEST", new Properties()));
shardingRuleConfig.getShardingAlgorithms().put("standard", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST", new Properties()));
assertTrue(new ShardingRule(shardingRuleConfig, createDataSourceNames()).isShardingColumn("column", "LOGIC_TABLE"));
}
......@@ -240,7 +239,7 @@ public final class ShardingRuleTest {
public void assertIsShardingColumnForDatabaseShardingStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTables().add(createTableRuleConfigWithAllStrategies());
shardingRuleConfig.getShardingAlgorithms().put("standard", new ShardingAlgorithmConfiguration("STANDARD_TEST", new Properties()));
shardingRuleConfig.getShardingAlgorithms().put("standard", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST", new Properties()));
assertTrue(new ShardingRule(shardingRuleConfig, createDataSourceNames()).isShardingColumn("column", "logic_Table"));
}
......@@ -248,7 +247,7 @@ public final class ShardingRuleTest {
public void assertIsShardingColumnForTableShardingStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTables().add(createTableRuleConfigWithTableStrategies());
shardingRuleConfig.getShardingAlgorithms().put("standard", new ShardingAlgorithmConfiguration("STANDARD_TEST", new Properties()));
shardingRuleConfig.getShardingAlgorithms().put("standard", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST", new Properties()));
assertTrue(new ShardingRule(shardingRuleConfig, createDataSourceNames()).isShardingColumn("column", "logic_Table"));
}
......@@ -353,9 +352,9 @@ public final class ShardingRuleTest {
shardingAlgorithmTBL.setProps(props);
shardingRuleConfiguration.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("table_id", "standard"));
shardingRuleConfiguration.setDefaultKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "default"));
shardingRuleConfiguration.getShardingAlgorithms().put("standard", new ShardingAlgorithmConfiguration("STANDARD_TEST", new Properties()));
shardingRuleConfiguration.getKeyGenerators().put("increment", new KeyGenerateAlgorithmConfiguration("INCREMENT", new Properties()));
shardingRuleConfiguration.getKeyGenerators().put("default", new KeyGenerateAlgorithmConfiguration("INCREMENT", new Properties()));
shardingRuleConfiguration.getShardingAlgorithms().put("standard", new ShardingSphereAlgorithmConfiguration("STANDARD_TEST", new Properties()));
shardingRuleConfiguration.getKeyGenerators().put("increment", new ShardingSphereAlgorithmConfiguration("INCREMENT", new Properties()));
shardingRuleConfiguration.getKeyGenerators().put("default", new ShardingSphereAlgorithmConfiguration("INCREMENT", new Properties()));
return new ShardingRule(shardingRuleConfiguration, createDataSourceNames());
}
......
......@@ -17,8 +17,8 @@
package org.apache.shardingsphere.sharding.yaml.swapper.algorithm;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgorithmConfiguration;
import org.junit.Test;
import java.util.Properties;
......@@ -30,7 +30,7 @@ public final class KeyGenerateAlgorithmConfigurationYamlSwapperTest {
@Test
public void assertSwapToYaml() {
YamlShardingSphereAlgorithmConfiguration actual = new KeyGenerateAlgorithmConfigurationYamlSwapper().swap(new KeyGenerateAlgorithmConfiguration("UUID", new Properties()));
YamlShardingSphereAlgorithmConfiguration actual = new KeyGenerateAlgorithmConfigurationYamlSwapper().swap(new ShardingSphereAlgorithmConfiguration("UUID", new Properties()));
assertThat(actual.getType(), is("UUID"));
assertThat(actual.getProps(), is(new Properties()));
}
......@@ -39,7 +39,7 @@ public final class KeyGenerateAlgorithmConfigurationYamlSwapperTest {
public void assertSwapToObject() {
YamlShardingSphereAlgorithmConfiguration yamlConfiguration = new YamlShardingSphereAlgorithmConfiguration();
yamlConfiguration.setType("UUID");
KeyGenerateAlgorithmConfiguration actual = new KeyGenerateAlgorithmConfigurationYamlSwapper().swap(yamlConfiguration);
ShardingSphereAlgorithmConfiguration actual = new KeyGenerateAlgorithmConfigurationYamlSwapper().swap(yamlConfiguration);
assertThat(actual.getType(), is("UUID"));
assertThat(actual.getProps(), is(new Properties()));
}
......
......@@ -17,8 +17,8 @@
package org.apache.shardingsphere.sharding.route.fixture;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.algorithm.ShardingAlgorithmConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
......@@ -42,10 +42,10 @@ public abstract class AbstractRoutingEngineTest {
shardingRuleConfig.getTables().add(createInlineTableRuleConfig("t_order", "ds_${0..1}.t_order_${0..1}", "t_order_${order_id % 2}", "ds_${user_id % 2}"));
Properties props = new Properties();
props.setProperty("algorithm.expression", "ds_${user_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_order_${order_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_order_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("t_order_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
return new ShardingRule(shardingRuleConfig, Arrays.asList("ds_0", "ds_1"));
}
......@@ -56,13 +56,13 @@ public abstract class AbstractRoutingEngineTest {
shardingRuleConfig.getBindingTableGroups().add("t_order,t_order_item");
Properties props = new Properties();
props.setProperty("algorithm.expression", "ds_${user_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_order_${order_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_order_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("t_order_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_order_item_${order_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_order_item_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("t_order_item_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
return new ShardingRule(shardingRuleConfig, Arrays.asList("ds_0", "ds_1"));
}
......@@ -73,20 +73,20 @@ public abstract class AbstractRoutingEngineTest {
shardingRuleConfig.getBroadcastTables().add("t_config");
Properties props = new Properties();
props.setProperty("algorithm.expression", "ds_${user_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_order_${order_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_order_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("t_order_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_order_item_${order_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_order_item_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("t_order_item_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
return new ShardingRule(shardingRuleConfig, Arrays.asList("ds_0", "ds_1"));
}
protected final ShardingRule createHintShardingRule() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTables().add(createTableRuleWithHintConfig());
shardingRuleConfig.getShardingAlgorithms().put("hint_test", new ShardingAlgorithmConfiguration("HINT_TEST", new Properties()));
shardingRuleConfig.getShardingAlgorithms().put("hint_test", new ShardingSphereAlgorithmConfiguration("HINT_TEST", new Properties()));
return new ShardingRule(shardingRuleConfig, Arrays.asList("ds_0", "ds_1"));
}
......@@ -96,13 +96,13 @@ public abstract class AbstractRoutingEngineTest {
new HintShardingStrategyConfiguration("hint_test"), createStandardShardingStrategyConfiguration("t_hint_ds_test_inline", "t_hint_ds_test_${order_id % 2}")));
shardingRuleConfig.getTables().add(createTableRuleConfig("t_hint_table_test", "ds_${0..1}.t_hint_table_test_${0..1}",
createStandardShardingStrategyConfiguration("ds_inline", "ds_${user_id % 2}"), new HintShardingStrategyConfiguration("hint_test")));
shardingRuleConfig.getShardingAlgorithms().put("hint_test", new ShardingAlgorithmConfiguration("HINT_TEST", new Properties()));
shardingRuleConfig.getShardingAlgorithms().put("hint_test", new ShardingSphereAlgorithmConfiguration("HINT_TEST", new Properties()));
Properties props = new Properties();
props.setProperty("algorithm.expression", "ds_${user_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_hint_ds_test_${order_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_hint_ds_test_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("t_hint_ds_test_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
return new ShardingRule(shardingRuleConfig, Arrays.asList("ds_0", "ds_1"));
}
......@@ -117,17 +117,17 @@ public abstract class AbstractRoutingEngineTest {
shardingRuleConfig.getTables().add(createInlineTableRuleConfig("t_user", "ds_${0..1}.t_user_${0..1}", "t_user_${user_id % 2}", "ds_${user_id % 2}"));
shardingRuleConfig.getTables().add(createTableRuleWithHintConfig());
shardingRuleConfig.getBindingTableGroups().add("t_order,t_order_item");
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("ds_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_order_${user_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_order_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("t_order_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_order_item_${user_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_order_item_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("t_order_item_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
props = new Properties();
props.setProperty("algorithm.expression", "t_user_${user_id % 2}");
shardingRuleConfig.getShardingAlgorithms().put("t_user_inline", new ShardingAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("hint_test", new ShardingAlgorithmConfiguration("HINT_TEST", new Properties()));
shardingRuleConfig.getShardingAlgorithms().put("t_user_inline", new ShardingSphereAlgorithmConfiguration("INLINE", props));
shardingRuleConfig.getShardingAlgorithms().put("hint_test", new ShardingSphereAlgorithmConfiguration("HINT_TEST", new Properties()));
return new ShardingRule(shardingRuleConfig, Arrays.asList("ds_0", "ds_1", "main"));
}
......
......@@ -15,18 +15,18 @@
* limitations under the License.
*/
package org.apache.shardingsphere.encrypt.api.config.algorithm;
package org.apache.shardingsphere.infra.config.algorithm;
import org.apache.shardingsphere.infra.config.TypedSPIConfiguration;
import java.util.Properties;
/**
* Encrypt algorithm configuration.
* ShardingSphere algorithm configuration.
*/
public final class EncryptAlgorithmConfiguration extends TypedSPIConfiguration {
public final class ShardingSphereAlgorithmConfiguration extends TypedSPIConfiguration {
public EncryptAlgorithmConfiguration(final String type, final Properties props) {
public ShardingSphereAlgorithmConfiguration(final String type, final Properties props) {
super(type, props);
}
}
......@@ -22,9 +22,9 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
import org.apache.shardingsphere.infra.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.masterslave.api.config.algorithm.LoadBalanceAlgorithmConfiguration;
import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import org.apache.shardingsphere.orchestration.center.config.CenterConfiguration;
import org.apache.shardingsphere.orchestration.center.config.OrchestrationConfiguration;
......@@ -123,7 +123,8 @@ public final class OrchestrationShardingSphereDataSourceTest {
private MasterSlaveRuleConfiguration getMasterSlaveRuleConfiguration() {
MasterSlaveDataSourceRuleConfiguration dataSourceConfiguration = new MasterSlaveDataSourceRuleConfiguration("ds_ms", "ds_m", Collections.singletonList("ds_s"), "roundRobin");
return new MasterSlaveRuleConfiguration(Collections.singleton(dataSourceConfiguration), ImmutableMap.of("roundRobin", new LoadBalanceAlgorithmConfiguration("ROUND_ROBIN", new Properties())));
return new MasterSlaveRuleConfiguration(
Collections.singleton(dataSourceConfiguration), ImmutableMap.of("roundRobin", new ShardingSphereAlgorithmConfiguration("ROUND_ROBIN", new Properties())));
}
@Test
......
......@@ -22,7 +22,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
import org.apache.shardingsphere.driver.orchestration.internal.datasource.OrchestrationShardingSphereDataSource;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.spring.boot.orchestration.util.EmbedTestingServer;
import org.junit.BeforeClass;
import org.junit.Test;
......@@ -68,8 +68,8 @@ public class OrchestrationSpringBootEncryptTest {
EncryptRuleConfiguration configuration =
(EncryptRuleConfiguration) shardingSphereDataSource.getSchemaContexts().getDefaultSchemaContext().getSchema().getConfigurations().iterator().next();
assertThat(configuration.getEncryptors().size(), is(1));
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = configuration.getEncryptors().get("order_encrypt");
assertThat(encryptAlgorithmConfiguration, instanceOf(EncryptAlgorithmConfiguration.class));
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = configuration.getEncryptors().get("order_encrypt");
assertThat(encryptAlgorithmConfiguration, instanceOf(ShardingSphereAlgorithmConfiguration.class));
assertThat(encryptAlgorithmConfiguration.getType(), is("AES"));
assertThat(configuration.getTables().size(), is(1));
assertThat(configuration.getTables().iterator().next().getColumns().iterator().next().getCipherColumn(), is("cipher_order_id"));
......
......@@ -22,7 +22,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
import org.apache.shardingsphere.driver.orchestration.internal.datasource.OrchestrationShardingSphereDataSource;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.algorithm.EncryptAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.spring.boot.orchestration.registry.TestCenterRepository;
import org.apache.shardingsphere.spring.boot.orchestration.util.EmbedTestingServer;
import org.junit.BeforeClass;
......@@ -81,8 +81,8 @@ public class OrchestrationSpringBootRegistryEncryptTest {
assertThat(embedDataSource.getUsername(), is("sa"));
EncryptRuleConfiguration configuration = (EncryptRuleConfiguration) encryptDataSource.getSchemaContexts().getDefaultSchemaContext().getSchema().getConfigurations().iterator().next();
assertThat(configuration.getEncryptors().size(), is(1));
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = configuration.getEncryptors().get("order_encrypt");
assertThat(encryptAlgorithmConfiguration, instanceOf(EncryptAlgorithmConfiguration.class));
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = configuration.getEncryptors().get("order_encrypt");
assertThat(encryptAlgorithmConfiguration, instanceOf(ShardingSphereAlgorithmConfiguration.class));
assertThat(encryptAlgorithmConfiguration.getType(), is("AES"));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册